次の方法で共有


InstanceQueryProvider クラス

すべてのインスタンス クエリ プロバイダーの基本クラスを表します。

名前空間: Microsoft.ApplicationServer.StoreManagement.Query
アセンブリ: Microsoft.ApplicationServer.StoreManagement (microsoft.applicationserver.storemanagement.dll)

使用法

構文

'宣言
Public MustInherit Class InstanceQueryProvider
    Inherits ProviderBase
public abstract class InstanceQueryProvider : ProviderBase
public ref class InstanceQueryProvider abstract : public ProviderBase
public abstract class InstanceQueryProvider extends ProviderBase
public abstract class InstanceQueryProvider extends ProviderBase

解説

次のコードに、このクラスのサンプル実装を示します。

    public sealed class MySqlInstanceQueryProvider : InstanceQueryProvider
    {

        string storeName;
        string ConnectionString { get; set; }

        public override void Initialize(string name, NameValueCollection config)
        {

            this.storeName = name;
            this.ConnectionString= config["connectionString"];

            // Initialize the base class
            base.Initialize(name, config);
        }

        public override InstanceQuery CreateInstanceQuery()
        {
            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(this.ConnectionString);
            connectionStringBuilder.AsynchronousProcessing = true;
            return new MySqlInstanceQuery(this.storeName, connectionStringBuilder.ConnectionString);
        }

        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();
                }
            }
        }
    }

継承の階層

System.Object
   System.Configuration.Provider.ProviderBase
    Microsoft.ApplicationServer.StoreManagement.Query.InstanceQueryProvider
       Microsoft.ApplicationServer.StoreManagement.Sql.Query.SqlInstanceQueryProvider

スレッド セーフ

この型のパブリック静的 (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

関連項目

参照

InstanceQueryProvider メンバー
Microsoft.ApplicationServer.StoreManagement.Query 名前空間