InstanceQueryProvider Class

Represents the base class for all instance query providers.

Namespace: Microsoft.ApplicationServer.StoreManagement.Query
Assembly: Microsoft.ApplicationServer.StoreManagement (in microsoft.applicationserver.storemanagement.dll)

'Usage
Dim instance As InstanceQueryProvider

public abstract class InstanceQueryProvider : ProviderBase
public abstract class InstanceQueryProvider extends ProviderBase
public abstract class InstanceQueryProvider extends ProviderBase

The following code shows you sample implementation of this class.


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


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Visual Studio 2010 and later, .NET Framework 4

Target Platforms

Windows 7; Windows Server 2008 R2; Windows Server 2008 Service Pack 2; Windows Vista Service Pack 2
  https://msdn.microsoft.com/en-us/library/microsoft.applicationserver.storemanagement.query 2011-08-26
Show: