DbProviderServices.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / DbProviderServices.cs / 1458001 / DbProviderServices.cs

                            //------------------------------------------------------------------------------ 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....]
// @backupOwner [....] 
//----------------------------------------------------------------------------- 

namespace System.Data.Common 
{

    using System.Collections.Generic;
    using System.Data.Common.CommandTrees; 
    using System.Data.Metadata.Edm;
    using System.Xml; 
    using System.Reflection; 
    using System.IO;
    using System.Data.Entity; 
    using System.Diagnostics;

    /// 
    /// The factory for building command definitions; use the type of this object 
    /// as the argument to the IServiceProvider.GetService method on the provider
    /// factory; 
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    [CLSCompliant(false)] 
    abstract public class DbProviderServices
    {
        /// 
        /// Create a Command Definition object given a command tree. 
        /// 
        /// command tree for the statement 
        /// an exectable command definition object 
        /// 
        /// This method simply delegates to the provider's implementation of CreateDbCommandDefinition. 
        /// 
        public DbCommandDefinition CreateCommandDefinition(DbCommandTree commandTree)
        {
            EntityUtil.CheckArgumentNull(commandTree, "commandTree"); 
            ValidateDataSpace(commandTree);
            StoreItemCollection storeMetadata = (StoreItemCollection)commandTree.MetadataWorkspace.GetItemCollection(DataSpace.SSpace); 
            Debug.Assert(storeMetadata.StoreProviderManifest != null, "StoreItemCollection has null StoreProviderManifest?"); 

            return CreateDbCommandDefinition(storeMetadata.StoreProviderManifest, commandTree); 
        }

        /// 
        /// Create a Command Definition object given a command tree. 
        /// 
        /// command tree for the statement 
        /// an exectable command definition object 
        /// 
        /// This method simply delegates to the provider's implementation of CreateDbCommandDefinition. 
        /// 
        public DbCommandDefinition CreateCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
        {
            try 
            {
                return CreateDbCommandDefinition(providerManifest, commandTree); 
            } 
            catch (ProviderIncompatibleException)
            { 
                throw;
            }
            catch (Exception e)
            { 
                if (EntityUtil.IsCatchableExceptionType(e))
                { 
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotCreateACommandDefinition, e); 
                }
                throw; 
            }
        }

        ///  
        /// Create a Command Definition object, given the provider manifest and command tree
        ///  
        /// provider manifest previously retrieved from the store provider 
        /// command tree for the statement
        /// an exectable command definition object 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected abstract DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree);

        ///  
        /// Ensures that the data space of the specified command tree is the target (S-) space
        ///  
        /// The command tree for which the data space should be validated 
        internal virtual void ValidateDataSpace(DbCommandTree commandTree)
        { 
            Debug.Assert(commandTree != null, "Ensure command tree is non-null before calling ValidateDataSpace");

            if (commandTree.DataSpace != DataSpace.SSpace)
            { 
                throw EntityUtil.ProviderIncompatible(Entity.Strings.ProviderRequiresStoreCommandTree);
            } 
        } 

        ///  
        /// Create a DbCommand object given a command tree.
        /// 
        /// command tree for the statement
        /// a command object 
        internal virtual DbCommand CreateCommand(DbCommandTree commandTree) {
            DbCommandDefinition commandDefinition = CreateCommandDefinition(commandTree); 
            DbCommand command = commandDefinition.CreateCommand(); 
            return command;
        } 

        /// 
        /// Create the default DbCommandDefinition object based on the prototype command
        /// This method is intended for provider writers to build a default command definition 
        /// from a command.
        /// Note: This will clone the prototype 
        ///  
        /// the prototype command
        /// an executable command definition object 
        public virtual DbCommandDefinition CreateCommandDefinition(DbCommand prototype) {
            return DbCommandDefinition.CreateCommandDefinition(prototype);
        }
 
        /// 
        /// Retrieve the provider manifest token based on the specified connection. 
        ///  
        /// The connection for which the provider manifest token should be retrieved.
        ///  
        /// The provider manifest token that describes the specified connection, as determined by the provider.
        /// 
        /// 
        /// This method simply delegates to the provider's implementation of GetDbProviderManifestToken. 
        /// 
        public string GetProviderManifestToken(DbConnection connection) { 
            try 
            {
                string providerManifestToken = GetDbProviderManifestToken(connection); 
                if (providerManifestToken == null)
                {
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotReturnAProviderManifestToken);
                } 
                return providerManifestToken;
            } 
            catch (ProviderIncompatibleException) 
            {
                throw; 
            }
            catch (Exception e)
            {
                if (EntityUtil.IsCatchableExceptionType(e)) 
                {
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotReturnAProviderManifestToken, e); 
                } 
                throw;
            } 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected abstract string GetDbProviderManifestToken(DbConnection connection); 

        public DbProviderManifest GetProviderManifest(string manifestToken) { 
            try 
            {
                DbProviderManifest providerManifest = GetDbProviderManifest(manifestToken); 
                if (providerManifest == null)
                {
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotReturnAProviderManifest);
                } 

                return providerManifest; 
            } 
            catch (ProviderIncompatibleException)
            { 
                throw;
            }
            catch (Exception e)
            { 
                if (EntityUtil.IsCatchableExceptionType(e)) {
                    throw EntityUtil.ProviderIncompatible(System.Data.Entity.Strings.ProviderDidNotReturnAProviderManifest, e); 
                } 
                throw;
            } 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected abstract DbProviderManifest GetDbProviderManifest(string manifestToken); 

        internal void SetParameterValue(DbParameter parameter, TypeUsage parameterType, object value) 
        { 
            EntityUtil.CheckArgumentNull(parameter, "parameter");
            EntityUtil.CheckArgumentNull(parameterType, "parameterType"); 

            this.SetDbParameterValue(parameter, parameterType, value);
        }
 
        //
        internal virtual void SetDbParameterValue(DbParameter parameter, TypeUsage parameterType, object value) 
        { 
            parameter.Value = value;
        } 

        /// 
        /// Create an instance of DbProviderServices based on the supplied DbConnection
        ///  
        /// The DbConnection to use
        /// An instance of DbProviderServices 
        public static DbProviderServices GetProviderServices(DbConnection connection) { 
            return GetProviderServices(GetProviderFactory(connection));
        } 

        internal static DbProviderFactory GetProviderFactory(string providerInvariantName)
        {
            EntityUtil.CheckArgumentNull(providerInvariantName, "providerInvariantName"); 
            DbProviderFactory factory;
            try 
            { 
                factory = DbProviderFactories.GetFactory(providerInvariantName);
            } 
            catch (ArgumentException e)
            {
                throw EntityUtil.Argument(Strings.EntityClient_InvalidStoreProvider, e);
            } 
            return factory;
        } 
 
        /// 
        /// Retrieve the DbProviderFactory based on the specified DbConnection 
        /// 
        /// The DbConnection to use
        /// An instance of DbProviderFactory
        public static DbProviderFactory GetProviderFactory(DbConnection connection) 
        {
            EntityUtil.CheckArgumentNull(connection, "connection"); 
            DbProviderFactory factory = connection.ProviderFactory; 
            if (factory == null)
            { 
                throw EntityUtil.ProviderIncompatible(
                    System.Data.Entity.Strings.EntityClient_ReturnedNullOnProviderMethod(
                        "get_ProviderFactory",
                        connection.GetType().ToString())); 
            }
            return factory; 
        } 

        internal static DbProviderServices GetProviderServices(DbProviderFactory factory) { 
            EntityUtil.CheckArgumentNull(factory, "factory");

            IServiceProvider serviceProvider = factory as IServiceProvider;
            if (serviceProvider == null) { 
                throw EntityUtil.ProviderIncompatible(System.Data.Entity.Strings.EntityClient_DoesNotImplementIServiceProvider(
                    factory.GetType().ToString())); 
            } 

            DbProviderServices providerServices = serviceProvider.GetService(typeof(DbProviderServices)) as DbProviderServices; 
            if (providerServices == null) {
                throw EntityUtil.ProviderIncompatible(
                    System.Data.Entity.Strings.EntityClient_ReturnedNullOnProviderMethod(
                        "GetService", 
                        factory.GetType().ToString()));
            } 
 
            return providerServices;
        } 

        /// 
        /// Return an XML reader which represents the CSDL description
        ///  
        /// An XmlReader that represents the CSDL description
        internal static XmlReader GetConceptualSchemaDescription() { 
            return DbProviderServices.GetXmlResource("System.Data.Resources.DbProviderServices.ConceptualSchemaDefinition.csdl"); 
        }
 
        internal static XmlReader GetXmlResource(string resourceName) {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
            return XmlReader.Create(stream, null, resourceName); 
        }
 
        ///  
        /// Generates a DDL script which creates schema objects (tables, primary keys, foreign keys)
        /// based on the contents of the storeItemCollection and targeted for the version of the backend corresponding to 
        /// the providerManifestToken.
        /// Individual statements should be separated using database-specific DDL command separator.
        /// It is expected that the generated script would be executed in the context of existing database with
        /// sufficient permissions, and it should not include commands to create the database, but it may include 
        /// commands to create schemas and other auxiliary objects such as sequences, etc.
        ///  
        /// The provider manifest token identifying the target version 
        /// The collection of all store items based on which the script should be created
        ///  
        /// A DDL script which creates schema objects based on contents of storeItemCollection
        /// and targeted for the version of the backend corresponding to the providerManifestToken.
        /// 
        public string CreateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection) 
        {
           return DbCreateDatabaseScript(providerManifestToken, storeItemCollection); 
        } 

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
        protected virtual string DbCreateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection)
        {
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportCreateDatabaseScript);
        } 

        ///  
        /// Creates a database indicated by connection and creates schema objects 
        /// (tables, primary keys, foreign keys) based on the contents of storeItemCollection.
        ///  
        /// Connection to a non-existent database that needs to be created
        /// and be populated with the store objects indicated by the storeItemCollection
        /// Execution timeout for any commands needed to create the database.
        /// The collection of all store items based on which the script should be created< 
        public void CreateDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        { 
            DbCreateDatabase(connection, commandTimeout, storeItemCollection); 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected virtual void DbCreateDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportCreateDatabase); 
        }
 
        ///  
        /// Returns a value indicating whether given database exists on the server
        /// and/or whether schema objects contained in teh storeItemCollection have been created. 
        /// If the provider can deduct the database only based on the connection, they do not need
        /// to additionally verify all elements of the storeItemCollection.
        /// 
        /// Connection to a database whose existence is checked by this method 
        /// Execution timeout for any commands needed to determine the existence of the database
        /// The collection of all store items contained in the database 
        /// whose existence is determined by this method< 
        /// Whether the database indicated by the connection and the storeItemCollection exist
        public bool DatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        {
            return DbDatabaseExists(connection, commandTimeout, storeItemCollection);
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected virtual bool DbDatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        { 
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportDatabaseExists);
        } 


        /// 
        /// Deletes all store objects specified in the store item collection from the database and the database itself. 
        /// 
        /// Connection to an existing database that needs to be deleted 
        /// Execution timeout for any commands needed to delete the database 
        /// The collection of all store items contained in the database that should be deleted<
        public void DeleteDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        {
            DbDeleteDatabase(connection, commandTimeout, storeItemCollection);
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected virtual void DbDeleteDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        { 
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportDeleteDatabase);
        } 
    }

}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....]
// @backupOwner [....] 
//----------------------------------------------------------------------------- 

namespace System.Data.Common 
{

    using System.Collections.Generic;
    using System.Data.Common.CommandTrees; 
    using System.Data.Metadata.Edm;
    using System.Xml; 
    using System.Reflection; 
    using System.IO;
    using System.Data.Entity; 
    using System.Diagnostics;

    /// 
    /// The factory for building command definitions; use the type of this object 
    /// as the argument to the IServiceProvider.GetService method on the provider
    /// factory; 
    ///  
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
    [CLSCompliant(false)] 
    abstract public class DbProviderServices
    {
        /// 
        /// Create a Command Definition object given a command tree. 
        /// 
        /// command tree for the statement 
        /// an exectable command definition object 
        /// 
        /// This method simply delegates to the provider's implementation of CreateDbCommandDefinition. 
        /// 
        public DbCommandDefinition CreateCommandDefinition(DbCommandTree commandTree)
        {
            EntityUtil.CheckArgumentNull(commandTree, "commandTree"); 
            ValidateDataSpace(commandTree);
            StoreItemCollection storeMetadata = (StoreItemCollection)commandTree.MetadataWorkspace.GetItemCollection(DataSpace.SSpace); 
            Debug.Assert(storeMetadata.StoreProviderManifest != null, "StoreItemCollection has null StoreProviderManifest?"); 

            return CreateDbCommandDefinition(storeMetadata.StoreProviderManifest, commandTree); 
        }

        /// 
        /// Create a Command Definition object given a command tree. 
        /// 
        /// command tree for the statement 
        /// an exectable command definition object 
        /// 
        /// This method simply delegates to the provider's implementation of CreateDbCommandDefinition. 
        /// 
        public DbCommandDefinition CreateCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
        {
            try 
            {
                return CreateDbCommandDefinition(providerManifest, commandTree); 
            } 
            catch (ProviderIncompatibleException)
            { 
                throw;
            }
            catch (Exception e)
            { 
                if (EntityUtil.IsCatchableExceptionType(e))
                { 
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotCreateACommandDefinition, e); 
                }
                throw; 
            }
        }

        ///  
        /// Create a Command Definition object, given the provider manifest and command tree
        ///  
        /// provider manifest previously retrieved from the store provider 
        /// command tree for the statement
        /// an exectable command definition object 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected abstract DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree);

        ///  
        /// Ensures that the data space of the specified command tree is the target (S-) space
        ///  
        /// The command tree for which the data space should be validated 
        internal virtual void ValidateDataSpace(DbCommandTree commandTree)
        { 
            Debug.Assert(commandTree != null, "Ensure command tree is non-null before calling ValidateDataSpace");

            if (commandTree.DataSpace != DataSpace.SSpace)
            { 
                throw EntityUtil.ProviderIncompatible(Entity.Strings.ProviderRequiresStoreCommandTree);
            } 
        } 

        ///  
        /// Create a DbCommand object given a command tree.
        /// 
        /// command tree for the statement
        /// a command object 
        internal virtual DbCommand CreateCommand(DbCommandTree commandTree) {
            DbCommandDefinition commandDefinition = CreateCommandDefinition(commandTree); 
            DbCommand command = commandDefinition.CreateCommand(); 
            return command;
        } 

        /// 
        /// Create the default DbCommandDefinition object based on the prototype command
        /// This method is intended for provider writers to build a default command definition 
        /// from a command.
        /// Note: This will clone the prototype 
        ///  
        /// the prototype command
        /// an executable command definition object 
        public virtual DbCommandDefinition CreateCommandDefinition(DbCommand prototype) {
            return DbCommandDefinition.CreateCommandDefinition(prototype);
        }
 
        /// 
        /// Retrieve the provider manifest token based on the specified connection. 
        ///  
        /// The connection for which the provider manifest token should be retrieved.
        ///  
        /// The provider manifest token that describes the specified connection, as determined by the provider.
        /// 
        /// 
        /// This method simply delegates to the provider's implementation of GetDbProviderManifestToken. 
        /// 
        public string GetProviderManifestToken(DbConnection connection) { 
            try 
            {
                string providerManifestToken = GetDbProviderManifestToken(connection); 
                if (providerManifestToken == null)
                {
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotReturnAProviderManifestToken);
                } 
                return providerManifestToken;
            } 
            catch (ProviderIncompatibleException) 
            {
                throw; 
            }
            catch (Exception e)
            {
                if (EntityUtil.IsCatchableExceptionType(e)) 
                {
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotReturnAProviderManifestToken, e); 
                } 
                throw;
            } 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected abstract string GetDbProviderManifestToken(DbConnection connection); 

        public DbProviderManifest GetProviderManifest(string manifestToken) { 
            try 
            {
                DbProviderManifest providerManifest = GetDbProviderManifest(manifestToken); 
                if (providerManifest == null)
                {
                    throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotReturnAProviderManifest);
                } 

                return providerManifest; 
            } 
            catch (ProviderIncompatibleException)
            { 
                throw;
            }
            catch (Exception e)
            { 
                if (EntityUtil.IsCatchableExceptionType(e)) {
                    throw EntityUtil.ProviderIncompatible(System.Data.Entity.Strings.ProviderDidNotReturnAProviderManifest, e); 
                } 
                throw;
            } 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected abstract DbProviderManifest GetDbProviderManifest(string manifestToken); 

        internal void SetParameterValue(DbParameter parameter, TypeUsage parameterType, object value) 
        { 
            EntityUtil.CheckArgumentNull(parameter, "parameter");
            EntityUtil.CheckArgumentNull(parameterType, "parameterType"); 

            this.SetDbParameterValue(parameter, parameterType, value);
        }
 
        //
        internal virtual void SetDbParameterValue(DbParameter parameter, TypeUsage parameterType, object value) 
        { 
            parameter.Value = value;
        } 

        /// 
        /// Create an instance of DbProviderServices based on the supplied DbConnection
        ///  
        /// The DbConnection to use
        /// An instance of DbProviderServices 
        public static DbProviderServices GetProviderServices(DbConnection connection) { 
            return GetProviderServices(GetProviderFactory(connection));
        } 

        internal static DbProviderFactory GetProviderFactory(string providerInvariantName)
        {
            EntityUtil.CheckArgumentNull(providerInvariantName, "providerInvariantName"); 
            DbProviderFactory factory;
            try 
            { 
                factory = DbProviderFactories.GetFactory(providerInvariantName);
            } 
            catch (ArgumentException e)
            {
                throw EntityUtil.Argument(Strings.EntityClient_InvalidStoreProvider, e);
            } 
            return factory;
        } 
 
        /// 
        /// Retrieve the DbProviderFactory based on the specified DbConnection 
        /// 
        /// The DbConnection to use
        /// An instance of DbProviderFactory
        public static DbProviderFactory GetProviderFactory(DbConnection connection) 
        {
            EntityUtil.CheckArgumentNull(connection, "connection"); 
            DbProviderFactory factory = connection.ProviderFactory; 
            if (factory == null)
            { 
                throw EntityUtil.ProviderIncompatible(
                    System.Data.Entity.Strings.EntityClient_ReturnedNullOnProviderMethod(
                        "get_ProviderFactory",
                        connection.GetType().ToString())); 
            }
            return factory; 
        } 

        internal static DbProviderServices GetProviderServices(DbProviderFactory factory) { 
            EntityUtil.CheckArgumentNull(factory, "factory");

            IServiceProvider serviceProvider = factory as IServiceProvider;
            if (serviceProvider == null) { 
                throw EntityUtil.ProviderIncompatible(System.Data.Entity.Strings.EntityClient_DoesNotImplementIServiceProvider(
                    factory.GetType().ToString())); 
            } 

            DbProviderServices providerServices = serviceProvider.GetService(typeof(DbProviderServices)) as DbProviderServices; 
            if (providerServices == null) {
                throw EntityUtil.ProviderIncompatible(
                    System.Data.Entity.Strings.EntityClient_ReturnedNullOnProviderMethod(
                        "GetService", 
                        factory.GetType().ToString()));
            } 
 
            return providerServices;
        } 

        /// 
        /// Return an XML reader which represents the CSDL description
        ///  
        /// An XmlReader that represents the CSDL description
        internal static XmlReader GetConceptualSchemaDescription() { 
            return DbProviderServices.GetXmlResource("System.Data.Resources.DbProviderServices.ConceptualSchemaDefinition.csdl"); 
        }
 
        internal static XmlReader GetXmlResource(string resourceName) {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
            return XmlReader.Create(stream, null, resourceName); 
        }
 
        ///  
        /// Generates a DDL script which creates schema objects (tables, primary keys, foreign keys)
        /// based on the contents of the storeItemCollection and targeted for the version of the backend corresponding to 
        /// the providerManifestToken.
        /// Individual statements should be separated using database-specific DDL command separator.
        /// It is expected that the generated script would be executed in the context of existing database with
        /// sufficient permissions, and it should not include commands to create the database, but it may include 
        /// commands to create schemas and other auxiliary objects such as sequences, etc.
        ///  
        /// The provider manifest token identifying the target version 
        /// The collection of all store items based on which the script should be created
        ///  
        /// A DDL script which creates schema objects based on contents of storeItemCollection
        /// and targeted for the version of the backend corresponding to the providerManifestToken.
        /// 
        public string CreateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection) 
        {
           return DbCreateDatabaseScript(providerManifestToken, storeItemCollection); 
        } 

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")] 
        protected virtual string DbCreateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection)
        {
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportCreateDatabaseScript);
        } 

        ///  
        /// Creates a database indicated by connection and creates schema objects 
        /// (tables, primary keys, foreign keys) based on the contents of storeItemCollection.
        ///  
        /// Connection to a non-existent database that needs to be created
        /// and be populated with the store objects indicated by the storeItemCollection
        /// Execution timeout for any commands needed to create the database.
        /// The collection of all store items based on which the script should be created< 
        public void CreateDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        { 
            DbCreateDatabase(connection, commandTimeout, storeItemCollection); 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected virtual void DbCreateDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportCreateDatabase); 
        }
 
        ///  
        /// Returns a value indicating whether given database exists on the server
        /// and/or whether schema objects contained in teh storeItemCollection have been created. 
        /// If the provider can deduct the database only based on the connection, they do not need
        /// to additionally verify all elements of the storeItemCollection.
        /// 
        /// Connection to a database whose existence is checked by this method 
        /// Execution timeout for any commands needed to determine the existence of the database
        /// The collection of all store items contained in the database 
        /// whose existence is determined by this method< 
        /// Whether the database indicated by the connection and the storeItemCollection exist
        public bool DatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        {
            return DbDatabaseExists(connection, commandTimeout, storeItemCollection);
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected virtual bool DbDatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        { 
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportDatabaseExists);
        } 


        /// 
        /// Deletes all store objects specified in the store item collection from the database and the database itself. 
        /// 
        /// Connection to an existing database that needs to be deleted 
        /// Execution timeout for any commands needed to delete the database 
        /// The collection of all store items contained in the database that should be deleted<
        public void DeleteDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        {
            DbDeleteDatabase(connection, commandTimeout, storeItemCollection);
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
        protected virtual void DbDeleteDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) 
        { 
            throw EntityUtil.ProviderIncompatible(Strings.ProviderDoesNotSupportDeleteDatabase);
        } 
    }

}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK