Share via


InstanceStoreProvider.UniqueProviderIdentifier メソッド

異なるプロバイダー オブジェクトが同じ基本ストアに解決されるかどうかを決定するために使用される、一意のプロバイダー ID を返します。

名前空間: Microsoft.ApplicationServer.StoreProvider
アセンブリ: Microsoft.ApplicationServer.StoreProvider (microsoft.applicationserver.storeprovider.dll)

使用法

構文

'宣言
Public MustOverride Function UniqueProviderIdentifier As String
public abstract string UniqueProviderIdentifier ()
public:
virtual String^ UniqueProviderIdentifier () abstract
public abstract String UniqueProviderIdentifier ()
public abstract function UniqueProviderIdentifier () : String

戻り値

文字列としての一意のプロバイダー ID です。

解説

次にサンプル コードを示します。

        string UniqueStoreIdentifier { get; set; }

        public override string UniqueProviderIdentifier()
        {   
            this.UniqueStoreIdentifier = GetUniqueStoreIdentifier(this.ConnectionString); 
            return this.UniqueStoreIdentifier;
        }

        private string GetUniqueStoreIdentifier(string connectionString)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = "SELECT TOP (1) [StoreIdentifier] FROM [Microsoft.ApplicationServer.DurableInstancing].[StoreVersion]";
                    command.Connection = connection;

                    command.Connection.Open();

                    Guid identifier = (Guid)command.ExecuteScalar();
                    return identifier.ToString();
                }
            }
        }

スレッド セーフ

この型のパブリック静的 (Visual Basic では Shared ) メンバーはスレッド セーフです。インスタンスのメンバーはいずれも、スレッド セーフである保証はありません。

プラットフォーム

開発プラットフォーム

Visual Studio 2010 およびそれ以降, .NET Framework 4

対象プラットフォーム

Windows 7; Windows Server 2008 R2; Windows Server 2008 Service Pack 2; Windows Vista Service Pack 2

Change History

関連項目

参照

InstanceStoreProvider クラス
InstanceStoreProvider メンバー
Microsoft.ApplicationServer.StoreProvider 名前空間