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

C# Dbml.Database类代码示例

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

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



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

示例1: WriteClass

        protected virtual void WriteClass(CodeWriter writer, Table table, Database schema, GenerationContext context)
        {
            writer.WriteLine();

            string entityBase = context.Parameters.EntityBase;
            if (string.IsNullOrEmpty(entityBase))
                entityBase = schema.EntityBase;

            var specifications = SpecificationDefinition.Partial;
            if (table.Type.AccessModifierSpecified)
                specifications |= GetSpecificationDefinition(table.Type.AccessModifier);
            else
                specifications |= SpecificationDefinition.Public;
            if (table.Type.ModifierSpecified)
                specifications |= GetSpecificationDefinition(table.Type.Modifier);

            var tableAttribute = NewAttributeDefinition<TableAttribute>();
            tableAttribute["Name"] = table.Name;
            using (writer.WriteAttribute(tableAttribute))
            using (writer.WriteClass(specifications,
                                     table.Type.Name, entityBase, context.Parameters.EntityInterfaces))
            {
                WriteClassHeader(writer, table, context);
                WriteCustomTypes(writer, table, schema, context);
                WriteClassExtensibilityDeclarations(writer, table, context);
                WriteClassProperties(writer, table, context);
                if (context.Parameters.GenerateEqualsHash)
                    WriteClassEqualsAndHash(writer, table, context);
                WriteClassChildren(writer, table, schema, context);
                WriteClassParents(writer, table, schema, context);
                WriteClassChildrenAttachment(writer, table, schema, context);
                WriteClassCtor(writer, table, schema, context);
            }
        }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:34,代码来源:CodeGenerator.Class.cs


示例2: CheckNames

 protected virtual void CheckNames(Database schema)
 {
     CheckNames(schema,
                column => "Contents",
                association => association.ThisKey + association.Member,
                association => association.Member + association.Type);
 }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:7,代码来源:SchemaLoader.Name.cs


示例3: WriteDataContextCtors

 protected virtual void WriteDataContextCtors(CodeWriter writer, Database schema, Type contextBaseType, GenerationContext context)
 {
     // ctor taking a connections tring
     WriteDataContextCtor(writer, schema, contextBaseType,
            new[] { new ParameterDefinition { Name = "connectionString", Type = typeof(string) } },
            new[] { "connectionString" },
            new[] { typeof(string) },
            context);
     // the two constructors below have the same prototype, so they are mutually exclusive
     // the base class requires a IVendor
     if (!WriteDataContextCtor(writer, schema, contextBaseType,
                          new[] { new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) } },
                          new[] { "connection", writer.GetNewExpression(writer.GetMethodCallExpression(writer.GetLiteralFullType(context.SchemaLoader.Vendor.GetType()))) },
                          new[] { typeof(IDbConnection), typeof(IVendor) },
                          context))
     {
         // OR the base class requires no IVendor
         WriteDataContextCtor(writer, schema, contextBaseType,
                              new[] { new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) } },
                              new[] { "connection" },
                              new[] { typeof(IDbConnection) },
                              context);
     }
     // ctor(string, MappingSource)
     WriteDataContextCtor(writer, schema, contextBaseType,
            new[] {
                new ParameterDefinition { Name = "connection", Type = typeof(string) },
                new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
            },
            new[] { "connection", "mappingSource" },
            new[] { typeof(string), typeof (MappingSource) },
            context);
     // ctor(IDbConnection, MappingSource)
     WriteDataContextCtor(writer, schema, contextBaseType,
             new[] {
                 new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
                 new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
             },
             new[] { "connection", "mappingSource" },
             new[] { typeof(IDbConnection), typeof(MappingSource) },
             context);
     // just in case you'd like to specify another vendor than the one who helped generating this file
     WriteDataContextCtor(writer, schema, contextBaseType,
             new[] {
                 new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
                 new ParameterDefinition { Name = "vendor", Type = typeof(IVendor) },
             },
             new[] { "connection", "vendor" },
             new[] { typeof(IDbConnection), typeof(IVendor) },
             context);
     WriteDataContextCtor(writer, schema, contextBaseType,
             new[] {
                 new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
                 new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
                 new ParameterDefinition { Name = "vendor", Type = typeof(IVendor) },
             },
             new[] { "connection", "mappingSource", "vendor" },
             new[] { typeof(IDbConnection), typeof(MappingSource), typeof(IVendor) },
             context);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:60,代码来源:CodeGenerator.Context.Ctor.cs


示例4: LoadConstraints

        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            //sort tables - parents first (this is moving to SchemaPostprocess)
            //TableSorter.Sort(tables, constraints); 

            foreach (DataConstraint keyColRow in constraints)
            {
                //find my table:
                string fullKeyDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => fullKeyDbName == t.Name);
                if (table == null)
                {
                    bool ignoreCase = true;
                    table = schema.Tables.FirstOrDefault(t => 0 == string.Compare(fullKeyDbName, t.Name, ignoreCase));
                    if (table == null)
                    {
                        WriteErrorLine("ERROR L46: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
                        continue;
                    }
                }

                bool isForeignKey = keyColRow.ConstraintName != "PRIMARY"
                                    && keyColRow.ReferencedTableName != null;

                if (isForeignKey)
                {
                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
                                   keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName, keyColRow.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);
                }

            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:FirebirdSchemaLoader.cs


示例5: GenerateVisualBasic

 /// <summary>
 /// Generates a Visual Basic source code wrapper for the database schema objects.
 /// </summary>
 /// <param name="database"></param>
 /// <param name="filename"></param>
 public void GenerateVisualBasic(Database database, string filename)
 {
     using (Stream stream = File.Open(filename, FileMode.Create))
     {
         using (StreamWriter writer = new StreamWriter(stream))
         {
             new VBCodeProvider().CreateGenerator(writer).GenerateCodeFromNamespace(GenerateCodeDomModel(database), writer, new CodeGeneratorOptions() { BracingStyle = "C" });
         }
     }
 }
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:AbstractCodeDomGenerator.cs


示例6: Write

 public void Write(TextWriter textWriter, Database dbSchema, GenerationContext context)
 {
     Context = context;
     Provider.CreateGenerator(textWriter).GenerateCodeFromNamespace(
         GenerateCodeDomModel(dbSchema), textWriter, 
         new CodeGeneratorOptions() {
             BracingStyle = "C",
             IndentString = "\t",
         });
 }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:10,代码来源:CodeDomGenerator.cs


示例7: LoadConstraints

        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            //TableSorter.Sort(tables, constraints); //sort tables - parents first

            var constraints = ReadConstraints(conn, schemaName.DbName);

            var allKeys2 = ReadForeignConstraints(conn, schemaName.DbName);
            var foreignKeys = allKeys2.Where(k => k.ConstraintType == "FOREIGN KEY").ToList();
            var primaryKeys = allKeys2.Where(k => k.ConstraintType == "PRIMARY KEY").ToList();


            foreach (DataConstraint keyColRow in constraints)
            {
                //find my table:
                string constraintFullDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L138: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
                    continue;
                }

                //todo: must understand better how PKEYs are encoded.
                //In Sasha's DB, they don't end with "_pkey", you need to rely on ReadForeignConstraints().
                //In Northwind, they do end with "_pkey".
                bool isPrimaryKey = keyColRow.ConstraintName.EndsWith("_pkey")
                    || primaryKeys.Count(k => k.ConstraintName == keyColRow.ConstraintName) == 1;

                if (isPrimaryKey)
                {
                    //A) add primary key
                    DbLinq.Schema.Dbml.Column primaryKeyCol = table.Type.Columns.First(c => c.Name == keyColRow.ColumnName);
                    primaryKeyCol.IsPrimaryKey = true;
                }
                else
                {
                    DataForeignConstraint dataForeignConstraint = foreignKeys.FirstOrDefault(f => f.ConstraintName == keyColRow.ConstraintName);

                    if (dataForeignConstraint == null)
                    {
                        string msg = "Missing data from 'constraint_column_usage' for foreign key " + keyColRow.ConstraintName;
                        WriteErrorLine(msg);
                        //throw new ApplicationException(msg);
                        continue; //as per Andrus, do not throw. //putting together an Adnrus_DB test case.
                    }

                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
                                   dataForeignConstraint.ColumnName, dataForeignConstraint.ReferencedTableName,
                                   dataForeignConstraint.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);

                }

            }
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:55,代码来源:PgsqlSchemaLoader.cs


示例8: WriteClasses

        protected virtual void WriteClasses(CodeWriter writer, Database schema, GenerationContext context)
        {
            IEnumerable<Table> tables = schema.Tables;

            var types = context.Parameters.GenerateTypes;
            if (types.Count > 0)
                tables = tables.Where(t => types.Contains(t.Type.Name));

            foreach (var table in tables)
                WriteClass(writer, table, schema, context);
        }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:11,代码来源:CodeGenerator.Class.cs


示例9: LoadForeignKey

        /// <summary>
        /// Loads the foreign key.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="table">The table.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="tableSchema">The table schema.</param>
        /// <param name="referencedColumnName">Name of the referenced column.</param>
        /// <param name="referencedTableName">Name of the referenced table.</param>
        /// <param name="referencedTableSchema">The referenced table schema.</param>
        /// <param name="constraintName">Name of the constraint.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="names">The names.</param>
        protected virtual void LoadForeignKey(Database schema, Table table, string columnName, string tableName, string tableSchema,
            string referencedColumnName, string referencedTableName, string referencedTableSchema,
            string constraintName,
            NameFormat nameFormat, Names names)
        {
            var foreignKey = BuildForeignKey(names.ColumnsNames[tableName], columnName);
            var reverseForeignKey = BuildForeignKey(names.ColumnsNames[referencedTableName], referencedColumnName);

            var associationName = CreateAssociationName(tableName, tableSchema,
                referencedTableName, referencedTableSchema, constraintName, foreignKey, nameFormat);

            //both parent and child table get an [Association]
            var assoc = new Association();
            assoc.IsForeignKey = true;
            assoc.Name = constraintName;
            assoc.Type = null;
            assoc.ThisKey = foreignKey;
            assoc.OtherKey = reverseForeignKey;
            assoc.Member = associationName.ManyToOneMemberName;
            assoc.CardinalitySpecified = false;
            // TODO: generate assoc.Cardinality?
            table.Type.Associations.Add(assoc);

            //and insert the reverse association:
            var reverseAssociation = new Association();
            reverseAssociation.Name = constraintName;
            reverseAssociation.Type = table.Type.Name;
            reverseAssociation.Member = associationName.OneToManyMemberName;
            reverseAssociation.CardinalitySpecified = false;
            // TODO: generate reverseAssociation.Cardinality?
            reverseAssociation.ThisKey = reverseForeignKey;
            reverseAssociation.OtherKey = foreignKey;
            reverseAssociation.DeleteRule = "NO ACTION";

            string referencedFullDbName = GetFullDbName(referencedTableName, referencedTableSchema);
            var referencedTable = schema.Tables.FirstOrDefault(t => referencedFullDbName == t.Name);
            if (referencedTable == null)
            {
                //try case-insensitive match 
                //reason: MySql's Key_Column_Usage table contains both 'Northwind' and 'northwind'
                referencedTable = schema.Tables.FirstOrDefault(t => referencedFullDbName.ToLower() == t.Name.ToLower());
            }

            if (referencedTable == null)
            {
                ReportForeignKeyError(schema, referencedFullDbName);
            }
            else
            {
                referencedTable.Type.Associations.Add(reverseAssociation);
                assoc.Type = referencedTable.Type.Name;
            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:67,代码来源:SchemaLoader.ForeignKey.cs


示例10: LoadConstraints

        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            foreach (DataConstraint constraint in constraints)
            {
                //find my table:
                string constraintFullDbName = GetFullDbName(constraint.TableName, constraint.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L100: Table '" + constraint.TableName + "' not found for column " + constraint.ColumnNameList);
                    continue;
                }

                //if (table.Name.StartsWith("E"))
                //    Logger.Write("---Dbg");

                if (constraint.ConstraintType == "P")
                {
                    //A) add primary key
                    DbLinq.Schema.Dbml.Column pkColumn = table.Type.Columns.Where(c => constraint.ColumnNames.Contains(c.Name)).First();
                    pkColumn.IsPrimaryKey = true;
                }
                else if (constraint.ConstraintType == "R")
                {
                    //if not PRIMARY, it's a foreign key. (constraint_type=="R")
                    //both parent and child table get an [Association]
                    DataConstraint referencedConstraint = constraints.FirstOrDefault(c => c.ConstraintName == constraint.ReverseConstraintName);
                    if (constraint.ReverseConstraintName == null || referencedConstraint == null)
                    {
                        WriteErrorLine("ERROR L127: given R_contraint_name='" + constraint.ReverseConstraintName + "', unable to find parent constraint");
                        continue;
                    }

                    LoadForeignKey(schema, table, constraint.ColumnNameList, constraint.TableName, constraint.TableSchema,
                                   referencedConstraint.ColumnNameList, referencedConstraint.TableName,
                                   referencedConstraint.TableSchema,
                                   constraint.ConstraintName, nameFormat, names);

                }
                // custom type, this is a trigger
                else if (constraint.ConstraintType == "T" && constraint.ColumnNames.Count == 1)
                {
                    var column = table.Type.Columns.Where(c => c.Name == constraint.ColumnNames[0]).First();
                    column.Expression = constraint.Expression;
                    column.IsDbGenerated = true;
                }
            }

            //GuessSequencePopulatedFields(schema);
        }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:52,代码来源:OracleSchemaLoader.cs


示例11: LoadConstraints

        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            //TableSorter.Sort(tables, constraints); //sort tables - parents first

            var foreignKeys = ReadConstraints(conn, schemaName.DbName);

            foreach (DataConstraint keyColRow in foreignKeys)
            {
                //find my table:
                string constraintFullDbName = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L138: Table '"
                                              + keyColRow.TableName
                                              + "' not found for column "
                                              + keyColRow.ColumnName);
                    continue;
                }

                if (keyColRow.ConstraintType.Equals("P")) //'PRIMARY KEY'
                {
                    //foreach (string pk_name in keyColRow.column_name_primaries)
                    //{
                    DbLinq.Schema.Dbml.Column primaryKeyCol = table.Type.Columns.First(c => c.Name == keyColRow.ColumnName);
                    primaryKeyCol.IsPrimaryKey = true;
                    //}
                    continue;
                }

                if (keyColRow.ConstraintType.Equals("R")) //'FOREIGN KEY'
                {
                    // This is very bad...
                    if (!names.ColumnsNames[keyColRow.ReferencedTableName].ContainsKey(keyColRow.ReferencedColumnName))
                        continue;

                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName,
                                   keyColRow.TableSchema,
                                   keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName,
                                   keyColRow.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);

                }

            }
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:46,代码来源:IngresSchemaLoader.cs


示例12: LoadStoredProcedures

        protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
        {
            var parameters = ReadParameters(conn, schemaName.DbName);
            foreach (var parameter in parameters)
            {
                var procedureName = CreateProcedureName(parameter.ProcedureName, parameter.Schema, nameFormat);

                Function function = schema.Functions.SingleOrDefault(f => f.Method == procedureName.MethodName);
                if (function == null)
                {
                    function = new Function { Name = procedureName.DbName, Method = procedureName.MethodName };
                    schema.Functions.Add(function);
                }

                if (parameter.Name == null)
                {
                    var returnParameter = new Return();
                    returnParameter.DbType = parameter.Type.SqlType;
                    returnParameter.Type = MapDbType(parameter.Name, parameter.Type).ToString();

                    function.IsComposable = true;
                    function.Return = returnParameter;
                }
                else
                {
                    var functionParameter = new Parameter();
                    functionParameter.DbType = parameter.Type.SqlType;
                    functionParameter.Type = MapDbType(parameter.Name, parameter.Type).ToString();
                    if (parameter.In)
                    {
                        if (parameter.Out)
                            functionParameter.Direction = DbLinq.Schema.Dbml.ParameterDirection.InOut;
                        else
                            functionParameter.Direction = DbLinq.Schema.Dbml.ParameterDirection.In;
                    }
                    else
                        functionParameter.Direction = DbLinq.Schema.Dbml.ParameterDirection.Out;

                    var parameterName = CreateParameterName(parameter.Name, nameFormat);
                    functionParameter.Name = parameterName.CallName;

                    function.Parameters.Add(functionParameter);
                }
            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:45,代码来源:OracleSchemaLoader.StoredProcedures.cs


示例13: CheckConstraintsName

 /// <summary>
 /// Checks for name conflicts, given lambdas to correct on conflicts
 /// </summary>
 /// <param name="schema"></param>
 /// <param name="tableNamedAssociationRenamer"></param>
 /// <param name="columnNamedAssociationRenamer"></param>
 protected virtual void CheckConstraintsName(Database schema,
                               Func<Association, string> tableNamedAssociationRenamer,
                               Func<Association, string> columnNamedAssociationRenamer)
 {
     foreach (var table in schema.Tables)
     {
         foreach (var association in table.Type.Associations)
         {
             var localAssociation = association;
             if (association.Member == table.Type.Name)
                 association.Member = tableNamedAssociationRenamer(association);
             else if ((from column in table.Type.Columns where column.Member == localAssociation.Member select column).FirstOrDefault() != null)
             {
                 association.Member = columnNamedAssociationRenamer(association);
             }
         }
     }
 }
开发者ID:Bewolf2,项目名称:GenesisMono,代码行数:24,代码来源:SchemaLoader.Name.cs


示例14: WriteDataContextCtor

 protected virtual bool WriteDataContextCtor(CodeWriter writer, Database schema, Type contextBaseType,
     ParameterDefinition[] parameters, string[] baseCallParameterNames, Type[] baseCallParameterTypes,
     GenerationContext context)
 {
     // if we have a contextBaseType, then check that we can do it
     if (contextBaseType != null)
     {
         var ctor = contextBaseType.GetConstructor(baseCallParameterTypes);
         if (ctor == null)
             return false;
     }
     using (writer.WriteCtor(SpecificationDefinition.Public, schema.Class, parameters, baseCallParameterNames))
     {
         writer.WriteLine(writer.GetStatement(writer.GetMethodCallExpression("OnCreated")));
     }
     writer.WriteLine();
     return true;
 }
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:CodeGenerator.Context.Ctor.cs


示例15: Load

        public virtual Database Load(string databaseName, INameAliases nameAliases, NameFormat nameFormat,
            bool loadStoredProcedures, string contextNamespace, string entityNamespace)
        {
            // check if connection is open. Note: we may use something more flexible
            if (Connection.State != ConnectionState.Open)
                Connection.Open();

            // get the database name. If we don't have one, take it from connection string...
            if (string.IsNullOrEmpty(databaseName))
                databaseName = Connection.Database;
            // ... and if connection string doesn't provide a name, then throw an error
            if (string.IsNullOrEmpty(databaseName))
                throw new ArgumentException("A database name is required. Please specify /database=<databaseName>");

            var schemaName = NameFormatter.GetSchemaName(databaseName, GetExtraction(databaseName), nameFormat);
            var names = new Names();
            var schema = new Database
                             {
                                 Name = schemaName.DbName,
                                 Class = schemaName.ClassName,
                                 BaseType = typeof(DataContext).FullName,
                                 ContextNamespace = contextNamespace,
                                 EntityNamespace = entityNamespace,
                             };

            // order is important, we must have:
            // 1. tables
            // 2. columns
            // 3. constraints
            LoadTables(schema, schemaName, Connection, nameAliases, nameFormat, names);
            LoadColumns(schema, schemaName, Connection, nameAliases, nameFormat, names);
            LoadConstraints(schema, schemaName, Connection, nameFormat, names);
            if (loadStoredProcedures)
                LoadStoredProcedures(schema, schemaName, Connection, nameFormat);
            CheckNamesCaseSafety(schema);

            // check for duplicate names between properties
            CheckNames(schema);
            // generate backing fields name (since we have here correct names)
            GenerateStorageFields(schema);

            return schema;
        }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:43,代码来源:SchemaLoader.cs


示例16: LoadStoredProcedures

        protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
        {
            var procs = ReadProcedures(conn, schemaName.DbName);

            foreach (DataStoredProcedure proc in procs)
            {
                var procedureName = CreateProcedureName(proc.specific_name, proc.db, nameFormat);

                var func = new Function();
                func.Name = procedureName.DbName;
                func.Method = procedureName.MethodName;
                func.IsComposable = string.Compare(proc.type, "FUNCTION") == 0;
                func.BodyContainsSelectStatement = proc.body != null
                                                   && proc.body.IndexOf("select", StringComparison.OrdinalIgnoreCase) > -1;
                ParseProcParams(proc, func);

                schema.Functions.Add(func);
            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:19,代码来源:MySqlSchemaLoader.cs


示例17: GenerateCodeDomModel

        protected virtual CodeNamespace GenerateCodeDomModel(Database database)
        {
            CodeNamespace _namespace = new CodeNamespace(database.ContextNamespace);

            _namespace.Imports.Add(new CodeNamespaceImport("System"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.ComponentModel"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Data"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Data.Linq.Mapping"));
            _namespace.Imports.Add(new CodeNamespaceImport("System.Diagnostics"));
            _namespace.Imports.Add(new CodeNamespaceImport("DbLinq.Linq"));
            _namespace.Imports.Add(new CodeNamespaceImport("DbLinq.Linq.Mapping"));

            _namespace.Comments.Add(new CodeCommentStatement(GenerateCommentBanner(database)));

            _namespace.Types.Add(GenerateContextClass(database));

            foreach (Table table in database.Tables)
                _namespace.Types.Add(GenerateTableClass(table));
            return _namespace;
        }
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:AbstractCodeDomGenerator.cs


示例18: CheckNamesCaseSafety

 protected virtual void CheckNamesCaseSafety(Database schema)
 {
     schema.Name = Vendor.SqlProvider.GetSafeName(schema.Name);
     foreach (var table in schema.Table)
     {
         table.Name = Vendor.SqlProvider.GetSafeName(table.Name);
         foreach (var column in table.Type.Columns)
         {
             column.Name = Vendor.SqlProvider.GetSafeName(column.Name);
         }
         foreach (var association in table.Type.Associations)
         {
             association.Name = Vendor.SqlProvider.GetSafeName(association.Name);
         }
     }
     foreach (var storedProcedure in schema.Functions)
     {
         storedProcedure.Name = Vendor.SqlProvider.GetSafeName(storedProcedure.Name);
     }
 }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:20,代码来源:SchemaLoader.Name.cs


示例19: LoadStoredProcedures

        protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
        {
            var procs = ReadProcedures(conn, schemaName.DbName);

            //4a. determine unknown types
            Dictionary<long, string> typeOidToName = new Dictionary<long, string>();

            foreach (DataStoredProcedure proc in procs)
            {
                if (proc.proallargtypes == null && !string.IsNullOrEmpty(proc.proargtypes))
                    proc.proallargtypes = "{" + proc.proargtypes.Replace(' ', ',') + "}"; //work around pgsql weirdness?
            }

            foreach (DataStoredProcedure proc in procs)
            {
                typeOidToName[proc.prorettype] = proc.formatted_prorettype;
                if (proc.proallargtypes == null)
                    continue; //no args, no Oids to resolve, skip

                string[] argTypes1 = parseCsvString(proc.proallargtypes); //eg. {23,24,1043}
                var argTypes2 = from t in argTypes1 select long.Parse(t);

                foreach (long argType in argTypes2)
                {
                    if (!typeOidToName.ContainsKey(argType))
                        typeOidToName[argType] = null;
                }
            }

            //4b. get names for unknown types
            GetTypeNames(conn, schemaName.DbName, typeOidToName);

            //4c. generate dbml objects
            foreach (DataStoredProcedure proc in procs)
            {
                DbLinq.Schema.Dbml.Function dbml_fct = ParseFunction(proc, typeOidToName, nameFormat);
                if (!SkipProc(dbml_fct.Name))
                    schema.Functions.Add(dbml_fct);
            }
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:40,代码来源:PgsqlSchemaLoader.cs


示例20: LoadStoredProcedures

        protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
        {
            // TODO: debug stored procedures support
            return;

            var procs = ReadProcedures(conn, schemaName.DbName);

            foreach (DataStoredProcedure proc in procs)
            {
                var procedureName = CreateProcedureName(proc.Name, proc.TableSchema, nameFormat);

                var func = new Function();

                func.Name = procedureName.DbName;
                func.Method = procedureName.MethodName;
                func.IsComposable = string.Compare(proc.Type, "FUNCTION") == 0;
                func.BodyContainsSelectStatement = proc.BodyContainsSelectStatement;
                ParseProcParams(proc, func);

                schema.Functions.Add(func);
            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:FirebirdSchemaLoader.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Debugger.Process类代码示例发布时间:2022-05-24
下一篇:
C# DbFuncionarios.BaseDeDados类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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