• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Edm.StoreItemCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.Metadata.Edm.StoreItemCollection的典型用法代码示例。如果您正苦于以下问题:C# StoreItemCollection类的具体用法?C# StoreItemCollection怎么用?C# StoreItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StoreItemCollection类属于System.Data.Metadata.Edm命名空间,在下文中一共展示了StoreItemCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateWrappedMetadataWorkspace

        private static MetadataWorkspace CreateWrappedMetadataWorkspace(string metadata, IEnumerable<string> wrapperProviderNames)
        {
            MetadataWorkspace workspace = new MetadataWorkspace();

            // parse Metadata keyword and load CSDL,SSDL,MSL files into XElement structures...
            var csdl = new List<XElement>();
            var ssdl = new List<XElement>();
            var msl = new List<XElement>();
            ParseMetadata(metadata, csdl, ssdl, msl);

            // fix all SSDL files by changing 'Provider' to our provider and modifying
            foreach (var ssdlFile in ssdl)
            {
                foreach (string providerName in wrapperProviderNames)
                {
                    ssdlFile.Attribute("ProviderManifestToken").Value = ssdl[0].Attribute("Provider").Value + ";" + ssdlFile.Attribute("ProviderManifestToken").Value;
                    ssdlFile.Attribute("Provider").Value = providerName;
                }
            }

            // load item collections from XML readers created from XElements...
            EdmItemCollection eic = new EdmItemCollection(csdl.Select(c => c.CreateReader()));
            StoreItemCollection sic = new StoreItemCollection(ssdl.Select(c => c.CreateReader()));
            StorageMappingItemCollection smic = new StorageMappingItemCollection(eic, sic, msl.Select(c => c.CreateReader()));

            // and create metadata workspace based on them.
            workspace = new MetadataWorkspace();
            workspace.RegisterItemCollection(eic);
            workspace.RegisterItemCollection(sic);
            workspace.RegisterItemCollection(smic);
            return workspace;
        }
开发者ID:peisheng,项目名称:EASYFRAMEWORK,代码行数:32,代码来源:EntityConnectionWrapperUtils.cs


示例2: CreateObjectsScript

        /// <summary>
        /// Helper function for generating the scripts for tables & constraints.
        /// </summary>
        /// <param name="itemCollection"></param>
        /// <returns></returns> 
        internal static List<string> CreateObjectsScript(StoreItemCollection itemCollection, bool returnWarnings)
        {
            var builder = new SqlDdlBuilder();

            // Iterate over the container.
            foreach (var container in itemCollection.GetItems<EntityContainer>())
            {
                // Generate create table statements.
                foreach (var set in container.BaseEntitySets)
                {
                    // If it is a type of entitySet, generate Create Table statements.
                    var entitySet = set as EntitySet;
                    if (entitySet != null)
                    {
                        builder.AppendCreateTable(entitySet);
                    }
                }

                // Generate Foreign Key constraints.
                foreach (var set in container.BaseEntitySets)
                {
                    // If it is association set, generate Foreign Key constraints.
                    var associationSet = set as AssociationSet;
                    if (associationSet != null)
                    {
                        builder.AppendCreateForeignKeys(associationSet);
                    }
                }
            }

            // Return the final command text.
            return builder.GetCommandText(returnWarnings);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:38,代码来源:SqlDdlBuilder.cs


示例3: StorageMappingItemCollection

        public StorageMappingItemCollection(EdmItemCollection edmCollection, StoreItemCollection storeCollection,
            params string[] filePaths)
            : base(DataSpace.CSSpace)
        {
            EntityUtil.CheckArgumentNull(edmCollection, "edmCollection");
            EntityUtil.CheckArgumentNull(storeCollection, "storeCollection");
            EntityUtil.CheckArgumentNull(filePaths, "filePaths");

            this.m_edmCollection = edmCollection;
            this.m_storeItemCollection = storeCollection;

            // Wrap the file paths in instances of the MetadataArtifactLoader class, which provides
            // an abstraction and a uniform interface over a diverse set of metadata artifacts.
            //
            MetadataArtifactLoader composite = null;
            List<XmlReader> readers = null;
            try
            {
                composite = MetadataArtifactLoader.CreateCompositeFromFilePaths(filePaths, XmlConstants.CSSpaceSchemaExtension);
                readers = composite.CreateReaders(DataSpace.CSSpace);

                this.Init(edmCollection, storeCollection, readers,
                          composite.GetPaths(DataSpace.CSSpace), true /*throwOnError*/);
            }
            finally
            {
                if (readers != null)
                {
                    Helper.DisposeXmlReaders(readers);
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:32,代码来源:StorageMappingItemCollection.cs


示例4: LegacyDbExpressionConverterTests

        public LegacyDbExpressionConverterTests()
        {
            const string ssdl =
                "<Schema Namespace='AdventureWorksModel.Store' Provider='System.Data.SqlClient' ProviderManifestToken='2008' xmlns='http://schemas.microsoft.com/ado/2009/11/edm/ssdl'>"
                +
                "  <EntityContainer Name='AdventureWorksModelStoreContainer'>" +
                "    <EntitySet Name='EntitiesSet' EntityType='AdventureWorksModel.Store.Entities' Schema='dbo' />" +
                "    <EntitySet Name='OtherEntitiesSet' EntityType='AdventureWorksModel.Store.OtherEntities' Schema='dbo' />" +
                "  </EntityContainer>" +
                "  <EntityType Name='Entities'>" +
                "    <Key>" +
                "      <PropertyRef Name='Id' />" +
                "    </Key>" +
                "    <Property Name='Id' Type='int' StoreGeneratedPattern='Identity' Nullable='false' />" +
                "    <Property Name='Name' Type='nvarchar(max)' Nullable='false' />" +
                "  </EntityType>" +
                "  <EntityType Name='OtherEntities'>" +
                "    <Key>" +
                "      <PropertyRef Name='Id' />" +
                "    </Key>" +
                "    <Property Name='Id' Type='int' StoreGeneratedPattern='Identity' Nullable='false' />" +
                "    <Property Name='Name' Type='nvarchar(max)' Nullable='false' />" +
                "  </EntityType>" +
                "</Schema>";

            _storeItemCollection = Utils.CreateStoreItemCollection(ssdl);
            _legacyStoreItemCollection = _storeItemCollection.ToLegacyStoreItemCollection();
            _legacyDbExpressionConverter = new LegacyDbExpressionConverter(_legacyStoreItemCollection);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:29,代码来源:LegacyDbExpressionConverterTests.cs


示例5: ToStoreLegacyType_returns_legacy_type_for_EntityType

        public void ToStoreLegacyType_returns_legacy_type_for_EntityType()
        {
            const string ssdl =
                "<Schema Namespace='AdventureWorksModel.Store' Provider='System.Data.SqlClient' ProviderManifestToken='2008' xmlns='http://schemas.microsoft.com/ado/2009/11/edm/ssdl'>"
                +
                "  <EntityContainer Name='AdventureWorksModelStoreContainer'>" +
                "    <EntitySet Name='Entities' EntityType='AdventureWorksModel.Store.Entities' Schema='dbo' />" +
                "  </EntityContainer>" +
                "  <EntityType Name='Entities'>" +
                "    <Key>" +
                "      <PropertyRef Name='Id' />" +
                "    </Key>" +
                "    <Property Name='Id' Type='int' StoreGeneratedPattern='Identity' Nullable='false' />" +
                "    <Property Name='Name' Type='nvarchar(max)' Nullable='false' />" +
                "  </EntityType>" +
                "</Schema>";

            var storeItemCollection = Utils.CreateStoreItemCollection(ssdl);
            var legacyStoreItemCollection =
                new LegacyMetadata.StoreItemCollection(new[] { XmlReader.Create(new StringReader(ssdl)) });

            var entityTypeUsage =
                TypeUsage.CreateDefaultTypeUsage(storeItemCollection.GetItem<EntityType>("AdventureWorksModel.Store.Entities"));
            var legacyEntityTypeUsage =
                entityTypeUsage.ToLegacyStoreTypeUsage(legacyStoreItemCollection.GetItems<LegacyMetadata.EdmType>().ToArray());

            TypeUsageVerificationHelper.VerifyTypeUsagesEquivalent(legacyEntityTypeUsage, entityTypeUsage);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:28,代码来源:TypeUsageExtensionsTests.cs


示例6: GenerateDatabaseScript

        public static string GenerateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection)
        {
            if (storeItemCollection == null)
                return string.Empty;

            var result = new StringBuilder();
            result.Append(string.Join(Environment.NewLine, GenerateTables(storeItemCollection)));
            result.AppendLine();
            result.Append(string.Join(Environment.NewLine, GenerateForeignKeys(storeItemCollection)));
            result.AppendLine();
            return result.ToString();
        }
开发者ID:nodoubt223rd,项目名称:nuodb-dotnet,代码行数:12,代码来源:ScriptBuilder.cs


示例7: DbDeleteDatabase

        /// <summary>
        /// API for deleting the database.
        /// In SQLCE case, this will translate to File.Delete() call.
        /// Note: Timeout and storeItemCollection parameters are ignored.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="timeOut"></param>
        /// <param name="storeItemCollection"></param>
        protected override void DbDeleteDatabase(DbConnection connection, int? timeOut, StoreItemCollection storeItemCollection)
        {
            // Validate that connection is a SqlCeConnection.
            ValidateConnection(connection);

            // We don't support create/delete database operations inside a transaction as they can't be rolled back.
            if (InTransactionScope())
            {
                throw ADP1.DeleteDatabaseNotAllowedWithinTransaction();
            }

            // Throw an exception if connection is open.
            // We should not close the connection because user could have result sets/data readers associated with this connection.
            // Thus, it is users responsiblity to close the connection before calling delete database.
            //
            if (connection.State
                == ConnectionState.Open)
            {
                throw ADP1.DeleteDatabaseWithOpenConnection();
            }

            if (_isLocalProvider)
            {
                CommonUtils.DeleteDatabase(connection.DataSource);
            }
            else
            {
                try
                {
                    Type rdpType;

                    // If we are working with RDP, then we will need to invoke the APIs through reflection.
                    var engine = RemoteProviderHelper.GetRemoteSqlCeEngine(connection.ConnectionString, out rdpType);
                    Debug.Assert(engine != null);

                    // Invoke the required method on SqlCeEngine.
                    var mi = rdpType.GetMethod("DeleteDatabaseWithError", new[] { typeof(string), typeof(int?) });
                    Debug.Assert(mi != null);

                    // We will pass 'timeout' to RDP, this will be used as timeout period for connecting and executing on TDSServer.
                    mi.Invoke(engine, new object[] { connection.DataSource, timeOut });
                }
                catch (Exception e)
                {
                    throw e.GetBaseException();
                }
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:56,代码来源:SqlCeProviderServices.cs


示例8: GenerateForeignKeys

 static IEnumerable<string> GenerateForeignKeys(StoreItemCollection storeItems)
 {
     foreach (var associationSet in storeItems.GetItems<EntityContainer>()[0].BaseEntitySets.OfType<AssociationSet>())
     {
         var result = new StringBuilder();
         ReferentialConstraint constraint = associationSet.ElementType.ReferentialConstraints.Single<ReferentialConstraint>();
         AssociationSetEnd end = associationSet.AssociationSetEnds[constraint.FromRole.Name];
         AssociationSetEnd end2 = associationSet.AssociationSetEnds[constraint.ToRole.Name];
         result.AppendFormat("ALTER TABLE {0}.{1} ADD FOREIGN KEY ({2}) REFERENCES {3}.{4}({5}){6};",
             SqlGenerator.QuoteIdentifier(MetadataHelpers.GetSchemaName(end2.EntitySet)),
             SqlGenerator.QuoteIdentifier(MetadataHelpers.GetTableName(end2.EntitySet)),
             string.Join(", ", constraint.ToProperties.Select(fk => SqlGenerator.QuoteIdentifier(fk.Name))),
             SqlGenerator.QuoteIdentifier(MetadataHelpers.GetSchemaName(end.EntitySet)),
             SqlGenerator.QuoteIdentifier(MetadataHelpers.GetTableName(end.EntitySet)),
             string.Join(", ", constraint.FromProperties.Select(pk => SqlGenerator.QuoteIdentifier(pk.Name))),
             end.CorrespondingAssociationEndMember.DeleteBehavior == OperationAction.Cascade ? " ON DELETE CASCADE" : string.Empty);
         yield return result.ToString();
     }
 }
开发者ID:nodoubt223rd,项目名称:nuodb-dotnet,代码行数:19,代码来源:ScriptBuilder.cs


示例9: Generate

        /// <summary>
        /// Main driver function.
        /// </summary>
        /// <param name="args"></param>
        public static void Generate(string outputFileName)
        {   
            //The following functions are omitted because they have counterparts in the BCL
            string[] omittedFunctions = new[]
            {
                "Sum", "Min", "Max", "Average", "Avg",
                "Count", "BigCount", 
                "Trim", "RTrim", "LTrim",
                "Concat", "Length", "Substring",
                "Replace", "IndexOf", "ToUpper", "ToLower",
                "Contains", "StartsWith", "EndsWith", "Year", "Month", "Day",
                "DayOfYear", "Hour", "Minute", "Second", "Millisecond", "CurrentDateTime", "CurrentDateTimeOffset",
                "CurrentUtcDateTime",
                "BitwiseAnd", "BitwiseOr", "BitwiseXor", "BitwiseNot",
                "Round", "Abs", "Power", "NewGuid",
                "Floor", "Ceiling",
            };

            //The following functions are omitted from SqlFunctions because they already exist in EntityFunctions
            string[] omittedSqlFunctions = new[]
            {
                "STDEV", "STDEVP", "VAR", "VARP", "COUNT_BIG",
                "Left", "Right", "Reverse", "GetTotalOffsetMinutes", 
                "TruncateTime", "CreateDateTime",
                "CreateDateTimeOffset", "CreateTime", "Add", "Diff",
                "Truncate", "SYSDATETIME", "SYSUTCDATETIME", "SYSDATETIMEOFFSET",
                "LEN", "LOWER", "UPPER", "NEWID", 
            };
                
            //Generate Sql Server function stubs
            String ssdl = @"<Schema Namespace='LinqFunctionStubsGenerator' Alias='Self' Provider='SampleEntityFrameworkProvider' ProviderManifestToken='2008' xmlns='http://schemas.microsoft.com/ado/2006/04/edm/ssdl'></Schema>";
            XmlReader[] xmlReaders = new XmlReader[1];
            xmlReaders[0] = XmlReader.Create(new StringReader(ssdl));

            StoreItemCollection storeItemCollection = new StoreItemCollection(xmlReaders);
            IEnumerable<EdmFunction> sqlFunctions = storeItemCollection.GetItems<EdmFunction>()
                .Where(f => f.NamespaceName == "SqlServer")
                .Where(f => !(omittedFunctions.Concat(omittedSqlFunctions)).Contains(f.Name, StringComparer.OrdinalIgnoreCase));

            FunctionStubFileWriter sqlStubsFileWriter = new FunctionStubFileWriter(sqlFunctions, GetFunctionNamingDictionary(), GetParameterNamingDictionary());
            sqlStubsFileWriter.GenerateToFile(outputFileName, "SampleEntityFrameworkProvider", "SampleSqlFunctions", "SqlServer", true);
        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:46,代码来源:LinqFunctionStubsCodeGen.cs


示例10: EntityModelSchemaGenerator

        public EntityModelSchemaGenerator(StoreItemCollection storeItemCollection, string namespaceName, string modelEntityContainerName)
        {
            EDesignUtil.CheckArgumentNull(storeItemCollection, "storeItemCollection");
            EDesignUtil.CheckArgumentNull(namespaceName, "namespaceName");
            EDesignUtil.CheckArgumentNull(modelEntityContainerName, "modelEntityContainerName");

            var storeContainers = storeItemCollection.GetItems<EntityContainer>().ToArray();
            if (storeContainers.Length != 1)
            {
                throw EDesignUtil.SingleStoreEntityContainerExpected("storeItemCollection");
            }

            Initialize(
                storeContainers[0],
                storeItemCollection.GetItems<EdmFunction>().Where(f => f.IsFromProviderManifest == false &&
                                                                       f.IsComposableAttribute == true &&
                                                                       f.AggregateAttribute == false),
                namespaceName,
                modelEntityContainerName);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:20,代码来源:EntityModelSchemaGenerator.cs


示例11: DbDatabaseExists

        protected override bool DbDatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");
            MySqlConnection conn = connection as MySqlConnection;
            if (conn == null)
                throw new ArgumentException(Resources.ConnectionMustBeOfTypeMySqlConnection, "connection");

            MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
            builder.ConnectionString = conn.ConnectionString;
            string dbName = builder.Database;
            builder.Database = "mysql";

            using (MySqlConnection c = new MySqlConnection(builder.ConnectionString))
            {
                c.Open();
                DataTable table = c.GetSchema("Databases", new string[] { dbName });
                if (table != null && table.Rows.Count == 1) return true;
                return false;
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:21,代码来源:EF4ProviderServices.cs


示例12: GenerateTables

 static IEnumerable<string> GenerateTables(StoreItemCollection storeItems)
 {
     foreach (var entitySet in storeItems.GetItems<EntityContainer>()[0].BaseEntitySets.OfType<EntitySet>())
     {
         var result = new StringBuilder();
         var tableName = MetadataHelpers.GetTableName(entitySet);
         var schemaName = MetadataHelpers.GetSchemaName(entitySet);
         result.AppendFormat("CREATE TABLE {0}.{1} (", SqlGenerator.QuoteIdentifier(schemaName), SqlGenerator.QuoteIdentifier(tableName));
         result.AppendLine();
         result.Append("\t");
         result.Append(string.Join("," + Environment.NewLine + "\t", MetadataHelpers.GetProperties(entitySet.ElementType).Select(p => GenerateColumn(p))));
         result.Append(");");
         result.AppendLine();
         result.AppendFormat("ALTER TABLE {0}.{1} ADD PRIMARY KEY ({2});",
             SqlGenerator.QuoteIdentifier(schemaName),
             SqlGenerator.QuoteIdentifier(tableName),
             string.Join(", ", entitySet.ElementType.KeyMembers.Select(pk => SqlGenerator.QuoteIdentifier(pk.Name))));
         result.AppendLine();
         yield return result.ToString();
     }
 }
开发者ID:nodoubt223rd,项目名称:nuodb-dotnet,代码行数:21,代码来源:ScriptBuilder.cs


示例13: DbDeleteDatabase

        protected override void DbDeleteDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");
            MySqlConnection conn = connection as MySqlConnection;
            if (conn == null)
                throw new ArgumentException(Resources.ConnectionMustBeOfTypeMySqlConnection, "connection");

            MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
            builder.ConnectionString = conn.ConnectionString;
            string dbName = builder.Database;
            builder.Database = "mysql";

            using (MySqlConnection c = new MySqlConnection(builder.ConnectionString))
            {
                c.Open();
                MySqlCommand cmd = new MySqlCommand(String.Format("DROP DATABASE IF EXISTS `{0}`", dbName), c);
                if (commandTimeout.HasValue)
                    cmd.CommandTimeout = commandTimeout.Value;
                cmd.ExecuteNonQuery();
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:22,代码来源:EF4ProviderServices.cs


示例14: DbCreateDatabase

        protected override void DbCreateDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");
            MySqlConnection conn = connection as MySqlConnection;
            if (conn == null)
                throw new ArgumentException(Resources.ConnectionMustBeOfTypeMySqlConnection, "connection");

            string query = DbCreateDatabaseScript(null, storeItemCollection);

            using (MySqlConnection c = new MySqlConnection())
            {
                MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder(conn.ConnectionString);
                string dbName = sb.Database;
                sb.Database = "mysql";
                c.ConnectionString = sb.ConnectionString;
                c.Open();

                string fullQuery = String.Format("CREATE DATABASE `{0}`; USE `{0}`; {1}", dbName, query);
                MySqlScript s = new MySqlScript(c, fullQuery);
                s.Execute();
            }
        }
开发者ID:elevate,项目名称:mysqlconnector-.net,代码行数:23,代码来源:EF4ProviderServices.cs


示例15: ToStorageMappingItemCollection

        private static StorageMappingItemCollection ToStorageMappingItemCollection(
            this DbDatabaseMapping databaseMapping, EdmItemCollection itemCollection,
            StoreItemCollection storeItemCollection)
        {
            //Contract.Requires(databaseMapping != null);
            //Contract.Requires(itemCollection != null);
            //Contract.Requires(storeItemCollection != null);

            var stringBuilder = new StringBuilder();

            using (var xmlWriter = XmlWriter.Create(
                stringBuilder, new XmlWriterSettings
                    {
                        Indent = true
                    }))
            {
                new MslSerializer().Serialize(databaseMapping, xmlWriter);
            }

            using (var xmlReader = XmlReader.Create(new StringReader(stringBuilder.ToString())))
            {
                return new StorageMappingItemCollection(itemCollection, storeItemCollection, new[] { xmlReader });
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:24,代码来源:DbDatabaseMappingExtensions.cs


示例16: DbDatabaseExists

        /// <summary>
        /// API for checkin whether database exists or not.
        /// This will internally only check whether the file that the connection points to exists or not.
        /// Note: In case of SQLCE, timeout and storeItemCollection parameters are ignored.
        /// </summary>
        /// <param name="connection">Connection</param>
        /// <param name="timeOut">Timeout for internal commands.</param>
        /// <param name="storeItemCollection">Item Collection.</param>
        /// <returns>Bool indicating whether database exists or not.</returns>
        protected override bool DbDatabaseExists(DbConnection connection, int? timeOut, StoreItemCollection storeItemCollection)
        {
            // Validate and cast the connection.
            ValidateConnection(connection);

            if (_isLocalProvider)
            {
                return CommonUtils.DatabaseExists(connection.DataSource);
            }
            else
            {
                Type rdpType;

                // If we are working with RDP, then we will need to invoke the APIs through reflection.
                var engine = RemoteProviderHelper.GetRemoteSqlCeEngine(connection.ConnectionString, out rdpType);
                Debug.Assert(engine != null);

                var mi = rdpType.GetMethod("FileExists", new[] { typeof(string), typeof(int?) });
                Debug.Assert(mi != null);

                // We will pass 'timeout' to RDP, this will be used as timeout period for connecting and executing on TDSServer.
                return (bool)(mi.Invoke(engine, new object[] { connection.DataSource, timeOut }));
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:33,代码来源:SqlCeProviderServices.cs


示例17: DbCreateDatabaseScript

    protected override string DbCreateDatabaseScript(string providerManifestToken,
        StoreItemCollection storeItemCollection)
    {
      StringBuilder sql = new StringBuilder();

      sql.AppendLine("-- MySql script");
      sql.AppendLine("-- Created on " + DateTime.Now);

      if (serverVersion == null)
        serverVersion = new Version(providerManifestToken == null ? "5.5" : providerManifestToken);

      foreach (EntityContainer container in storeItemCollection.GetItems<EntityContainer>())
      {
        // now output the tables
        foreach (EntitySet es in container.BaseEntitySets.OfType<EntitySet>())
        {
          sql.Append(GetTableCreateScript(es));
        }

        // now output the foreign keys
        foreach (AssociationSet a in container.BaseEntitySets.OfType<AssociationSet>())
        {
          sql.Append(GetAssociationCreateScript(a.ElementType));
        }
      }

      return sql.ToString();
    }
开发者ID:luguandao,项目名称:MySql.Data,代码行数:28,代码来源:ProviderServices.cs


示例18: DbDatabaseExists

        protected override bool DbDatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection must not be null");

            if (storeItemCollection == null)
                throw new ArgumentNullException("storeItemCollection must not be null");

            SampleConnection sampleConnection = connection as SampleConnection;
            if (sampleConnection == null)
                throw new ArgumentException("connection must be a valid SampleConnection");

            string databaseName = GetDatabaseName(sampleConnection);

            bool exists = false;
            UsingMasterConnection(sampleConnection, conn =>
            {
                StoreVersion storeVersion = StoreVersionUtils.GetStoreVersion(conn);
                string databaseExistsScript = DdlBuilder.CreateDatabaseExistsScript(databaseName);

                int result = (int)CreateCommand(conn, databaseExistsScript, commandTimeout).ExecuteScalar();
                exists = (result == 1);
            });

            return exists;
        }       
开发者ID:jesusico83,项目名称:Telerik,代码行数:26,代码来源:ProviderServices.cs


示例19: DbDeleteDatabase

        protected override void DbDeleteDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection must not be null");

            if (storeItemCollection == null)
                throw new ArgumentNullException("storeItemCollection must not be null");

            SampleConnection sampleConnection = connection as SampleConnection;
            if (sampleConnection == null)
                throw new ArgumentException("connection must be a valid SampleConnection");

            string databaseName = GetDatabaseName(sampleConnection);
            string dropDatabaseScript = DdlBuilder.DropDatabaseScript(databaseName);

            // clear the connection pool in case someone is holding on to the database
            sampleConnection.ClearPool();

            UsingMasterConnection(sampleConnection, (conn) =>
            {
                CreateCommand(conn, dropDatabaseScript, commandTimeout).ExecuteNonQuery();
            });
        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:23,代码来源:ProviderServices.cs


示例20: DbCreateDatabaseScript

        protected override string DbCreateDatabaseScript(string providerManifestToken, StoreItemCollection storeItemCollection)
        {
            if (providerManifestToken == null)
                throw new ArgumentNullException("providerManifestToken must not be null");

            if( storeItemCollection == null)
                throw new ArgumentNullException("storeItemCollection must not be null");
            
            return DdlBuilder.CreateObjectsScript(storeItemCollection);            
        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:10,代码来源:ProviderServices.cs



注:本文中的System.Data.Metadata.Edm.StoreItemCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Objects.ObjectParameter类代码示例发布时间:2022-05-26
下一篇:
C# Edm.EntityType类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap