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

C# TableSchema类代码示例

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

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



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

示例1: WriteToFile

        private static void WriteToFile(string folderPath, string nameSpace, bool keepDefaultValue, bool withUnderlinePrefix, MemberAccessPrivilege accessPrivilege, TableSchema tableSchema)
        {
            var fieldSchemaList = Mapper.Map<List<TableColumnSchema>, List<Field>>(tableSchema);
            var propertySchemaList = Mapper.Map<List<TableColumnSchema>, List<Property>>(tableSchema);
            var model = Mapper.Map<TableSchema, Model>(tableSchema);

            // update flag to decide keeping default value or not
            fieldSchemaList.Each(field => field.KeepDefaultValue = keepDefaultValue);
            // update flag for nameing rule -- underline prefix
            fieldSchemaList.Each(field => field.WithUnderlinePrefixNamingRule = withUnderlinePrefix);

            model.Namespace = nameSpace;
            model.AccessPrivilege = accessPrivilege;
            model.AddRange(fieldSchemaList);
            model.AddRange(propertySchemaList);

            var code = model.Serialize();

            using (FileStream stream = new FileStream(Path.Combine(folderPath, model.ModelName + ".cs"), FileMode.OpenOrCreate))
            using (var writer = new StreamWriter(stream, System.Text.Encoding.UTF8))
            {
                stream.SetLength(0);
                writer.Write(code);
                writer.Flush();
                writer.Close();
            }
        }
开发者ID:wbqsln,项目名称:HitStock,代码行数:27,代码来源:CreateModelByTableSchemaForm.cs


示例2: EndTableLoad

		public override void EndTableLoad(IDbConnection connection, TableSchema table)
		{
			foreach (var column in table.Columns)
			{
				// Update sequence to make sure that next generated value
				// will not cause a constraint violation.
				//
				if (!column.AutoIncrement)
					continue;
				using (var cmd = connection.CreateCommand())
				{
					cmd.CommandText = @"SELECT MAX(" + MakeDdlElementName(column.Name) +
						@") FROM " + MakeDdlElementName(table.Name);
					cmd.CommandTimeout = 0;

					var maxValue = Convert.ToInt32(cmd.ExecuteScalar());

					if (maxValue <= 0)
						continue;
					var genName = ParseName(_generatorPrefix, table.Name, column.Name);

					var dbsmGenerator = new DBGenerator {Name = genName, StartValue = maxValue};

					cmd.CommandText = MakeDdlGeneratorSet(dbsmGenerator);
					cmd.ExecuteNonQuery();
				}
			}

			base.EndTableLoad(connection, table);
		}
开发者ID:permyakov,项目名称:janus,代码行数:30,代码来源:FBSchemaDriver.cs


示例3: GetTables

		public override TableSchemaCollection GetTables ()
		{
			TableSchemaCollection tables = new TableSchemaCollection ();
			
			IPooledDbConnection conn = connectionPool.Request ();
			// Tables need to be ordered bacause TableSchemaCollection is "created" as sorted by default.
			IDbCommand command = conn.CreateCommand (
				"SELECT name, sql FROM sqlite_master WHERE type = 'table' ORDER BY name"
			);
			try {
				using (command) {
					using (IDataReader r = command.ExecuteReader()) {
						while (r.Read ()) {
							TableSchema table = new TableSchema (this);
		
							table.SchemaName = "main";
							table.Name = r.GetString (0);
							table.IsSystemTable = table.Name.StartsWith ("sqlite_");
							table.Definition = r.GetString (1);
							
							tables.Add (table);
						}
						r.Close ();
					}
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();

			return tables;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:32,代码来源:SqliteSchemaProvider.cs


示例4: IsManyToManyTable

 public static bool IsManyToManyTable(TableSchema table)
 {
     return (table.Columns.Count == 2 &&
         table.HasPrimaryKey() &&
         table.PrimaryKeyColumns().Count == 2 &&
         table.InReferences.Count == 2);
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:7,代码来源:Helper.cs


示例5: RunTableTemplate

        public static void RunTableTemplate(CodeTemplate Parent, TableSchema SourceTable, string Path, string Template, string Output, bool debug)
        {
            // admin datamodel
            try
            {

                PreserveRegionsMergeStrategy strategy = new PreserveRegionsMergeStrategy("^[ \t]*(?i:Custom)", "C#");
                CodeTemplate template = null;
                if (!debug)
                {
                    template = Parent.GetCodeTemplateInstance(Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                }
                else
                {
                    template = CompileTemplate(Parent, Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                }

                if (template != null)
                {
                    template.SetProperty("SourceTable", SourceTable);
                    template.RenderToFile(Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Output, strategy);
                    Parent.Response.WriteLine("File: " + Output + " Created Successfully");
                }
                else
                {
                    Parent.Response.WriteLine("Template is null: " + Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                }
            }
            catch (Exception ex)
            {
                Parent.Response.WriteLine("Template: " + Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                Parent.Response.WriteLine("Error: " + ex.Message);
                Parent.Response.WriteLine("StackTrace: " + ex.StackTrace);
            }
        }
开发者ID:smacinn,项目名称:CodeSmithHelper,代码行数:35,代码来源:Template.cs


示例6: GetSchema

        public DbSchema GetSchema()
        {
            var schema = new DbSchema();
            var map = _configuration.BuildMapping();
            var mappings = _configuration.ClassMappings;

            foreach(var class_map in mappings)
            {
                var table = class_map.Table;
                var table_schema = new TableSchema() {TableName = table.Name, SchemaName = table.Schema};
                foreach (var column in table.ColumnIterator)
                {

                    var type_code = column.GetSqlTypeCode(map);

                    var columnSchema = new ColumnSchema()
                                           {
                                               TableName = table_schema.TableName,
                                               ColumnName = column.Name,
                                               IsNullable = column.IsNullable,
                                               DatabaseType = type_code.DbType,
                                               Size = column.Length,
                                               Scale = column.Scale,
                                               Precision = column.Precision,
                                               IsPrimaryKey = table.PrimaryKey.Columns.Contains(column)
                                           };

                    // columnSchema.DatabaseType = property.GetSqlTypeCode(map).DbType;
                    table_schema.AddColumn(columnSchema);
                }
                schema.AddTable(table_schema);
            }
            return schema;
        }
开发者ID:jcteague,项目名称:SchemaMigrator,代码行数:34,代码来源:NhibernateSchemaBuilder.cs


示例7: ShowTableEditorDialog

		public bool ShowTableEditorDialog (IEditSchemaProvider schemaProvider, TableSchema table, bool create)
		{
			TableEditorSettings settings = new TableEditorSettings ();
			settings.ConstraintSettings.CheckSettings.SupportsColumnConstraints = false;
			TableEditorDialog dlg = new TableEditorDialog (schemaProvider, create, settings);
			dlg.Initialize (table);
			return RunDialog (dlg);
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:MySqlGuiProvider.cs


示例8: ShowTableEditorDialog

		public bool ShowTableEditorDialog (IEditSchemaProvider schemaProvider, TableSchema table, bool create)
		{
			TableEditorSettings settings = new TableEditorSettings ();
			TableEditorDialog dlg = new TableEditorDialog (schemaProvider, create, settings);
			dlg.Initialize (table);

			return RunDialog (dlg);
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:SqlServerGuiProvider.cs


示例9: Join

 /// <summary>
 /// Initializes a new instance of the <see cref="Join"/> class.
 /// </summary>
 /// <param name="from">From.</param>
 /// <param name="to">To.</param>
 /// <param name="joinType">Type of the join.</param>
 public Join(TableSchema.TableColumn from, TableSchema.TableColumn to, JoinType joinType,params string[] joinExpressions)
 {
     FromColumn = from;
     ToColumn = to;
     Type = joinType;
     if (joinExpressions != null && joinExpressions.Length > 0)
         JoinExpressions.AddRange(joinExpressions);
 }
开发者ID:eleooo,项目名称:App,代码行数:14,代码来源:Join.cs


示例10: EndTableLoad

		public override void EndTableLoad(IDbConnection connection, TableSchema table)
		{
			if (TableHasIdentityColumns(table))
				using (var cmd = connection.CreateCommand())
				{
					cmd.CommandText = @"SET IDENTITY_INSERT " + MakeDdlElementName(table.Name) + @" OFF";
					cmd.ExecuteNonQuery();
				}

			base.EndTableLoad(connection, table);
		}
开发者ID:rsdn,项目名称:janus,代码行数:11,代码来源:MssqlSchemaDriver.cs


示例11: GetClassNameFromTable

 /// <summary>
 /// Helper to generate class name from a table
 /// </summary>
 /// <param name="table"></param>
 /// <param name="prefix"></param>
 /// <param name="strip"></param>
 /// <returns>string</returns>
 public static string GetClassNameFromTable(TableSchema table, string prefix, string postfix, string strip)
 {
     if (strip != string.Empty)
     {
         return prefix + table.Name.Replace(strip, "").ToCSharpIdentifier().ToPascalCase() + postfix;
     }
     else
     {
         return prefix + table.Name.ToCSharpIdentifier().ToPascalCase() + postfix;
     }
 }
开发者ID:smacinn,项目名称:CodeSmithHelper,代码行数:18,代码来源:DB.cs


示例12: RelationParsingTest

        static RelationParsingTest()
        {
            NumbersSchema = new TableSchema("Numbers");
            PowersSchema = new TableSchema("Powers");

            NumbersSchema.Columns.AddValueColumn("Number", typeof(int), 0);
            NumbersSchema.Columns.AddValueColumn("IsEven", typeof(bool), false);

            PowersKeyColumn = PowersSchema.Columns.AddForeignKey("Number", NumbersSchema, "Powers");

            PowersSchema.Columns.AddValueColumn("Exponent", typeof(int), 0);
            PowersSchema.Columns.AddValueColumn("Value", typeof(int), 0);
        }
开发者ID:ShomreiTorah,项目名称:Libraries,代码行数:13,代码来源:RelationParsingTest.cs


示例13: GetTables

		private static List<TableSchema> GetTables(SqlConnection con)
		{
			var tables = new List<TableSchema>();
			string[] restrict4 = {null, null, null, "TABLE"};
			string[] restrict3 = {null, null, null};

			var dtTables = SqlSchemaFactory.GetSchema(con, "Tables", restrict4);
			for (var i = 0; i < dtTables.Rows.Count; i++)
			{
				var tRow = dtTables.Rows[i];
				var eTable = new TableSchema {Name = tRow["TABLE_NAME"].ToString()};
				// Columns
				restrict3[0] = null;
				restrict3[1] = null;
				restrict3[2] = eTable.Name;

				var dtShema = SqlSchemaFactory.GetSchema(con, "Columns", restrict3);
				if (dtShema.Rows.Count > 0)
				{
					eTable.Columns = new TableColumnSchema[dtShema.Rows.Count];

					for (var j = 0; j < dtShema.Rows.Count; j++)
					{
						var cRow = dtShema.Rows[j];

						var eColumn = new TableColumnSchema
						{
							Name = cRow["COLUMN_NAME"].ToString(),
							Size = Convert.ToInt32(cRow["COLUMN_SIZE"], CultureInfo.InvariantCulture),
							Type = TypeSqlToDbsm(cRow["COLUMN_DATA_TYPE"].ToString()),
							Nullable = Convert.ToBoolean(cRow["IS_NULLABLE"], CultureInfo.InvariantCulture),
							DefaultValue = cRow["COLUMN_DEFAULT"].ToString(),
							Increment = Convert.ToInt32(cRow["IDENTITY_INCREMENT"], CultureInfo.InvariantCulture),
							Seed = Convert.ToInt32(cRow["IDENTITY_SEED"], CultureInfo.InvariantCulture),
							AutoIncrement = Convert.ToBoolean(cRow["IS_IDENTITY"], CultureInfo.InvariantCulture),
							DecimalPrecision = Convert.ToInt32(cRow["NUMERIC_PRECISION"], CultureInfo.InvariantCulture),
							DecimalScale = Convert.ToInt32(cRow["NUMERIC_SCALE"], CultureInfo.InvariantCulture)
						};
						eColumn.DefaultValue = string.IsNullOrEmpty(eColumn.DefaultValue)
												? null
												: UnBracket.ParseUnBracket(eColumn.DefaultValue);

						eTable.Columns[j] = eColumn;
					}
				}

				tables.Add(eTable);
			}
			return tables;
		}
开发者ID:rsdn,项目名称:janus,代码行数:50,代码来源:MssqlSchemaLoader.cs


示例14: IsChildFKColumn

 public static bool IsChildFKColumn(ColumnSchema column, TableSchema table)
 {
     foreach (ReferenceSchema inReference in table.InReferences)
     {
         foreach (ReferenceJoin join in inReference.Joins)
         {
             //Found the child Column...
             if (join.ChildColumn.ObjectID == column.ObjectID)
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:15,代码来源:Helper.cs


示例15: GetTables

		private static List<TableSchema> GetTables(FbConnection con)
		{
			string[] restrict3 = {null, null, null};
			string[] restrict4 = {null, null, null, null};
			var aStore = new List<TableSchema>();

			restrict4[0] = null;
			restrict4[1] = null;
			restrict4[2] = null;
			restrict4[3] = "TABLE";
			var dtTables = con.GetSchema("Tables", restrict4);
			for (var i = 0; i < dtTables.Rows.Count; i++)
			{
				var tRow = dtTables.Rows[i];
				var eTable = new TableSchema {Name = tRow["TABLE_NAME"].ToString()};
				// Columns
				restrict3[0] = null;
				restrict3[1] = null;
				restrict3[2] = eTable.Name;
				var dtShema = con.GetSchema("Columns", restrict3);
				if (dtShema.Rows.Count > 0)
					eTable.Columns = new TableColumnSchema[dtShema.Rows.Count];
				for (var j = 0; j < dtShema.Rows.Count; j++)
				{
					var cRow = dtShema.Rows[j];

					var eColumn = new TableColumnSchema
									{
									Name = cRow["COLUMN_NAME"].ToString(),
									Size = Convert.ToInt32(cRow["COLUMN_SIZE"], CultureInfo.InvariantCulture),
									Type = TypeFbToDbsm(cRow["COLUMN_DATA_TYPE"].ToString()),
									Nullable = Convert.ToBoolean(cRow["IS_NULLABLE"], CultureInfo.InvariantCulture)
									};
					eColumn.DefaultValue = HelpDbscColumnDefault(con, eColumn.Name, eTable.Name);
					eColumn.DefaultValue = string.IsNullOrEmpty(eColumn.DefaultValue) ? null : eColumn.DefaultValue;
					eColumn.DecimalPrecision = cRow["NUMERIC_PRECISION"] == DBNull.Value
												? 0
												: Convert.ToInt32(cRow["NUMERIC_PRECISION"], CultureInfo.InvariantCulture);
					eColumn.DecimalScale = Convert.ToInt32(cRow["NUMERIC_SCALE"], CultureInfo.InvariantCulture);

					eTable.Columns[j] = eColumn;
				}
				aStore.Add(eTable);
			}
			return aStore;
		}
开发者ID:rsdn,项目名称:janus,代码行数:46,代码来源:FBSchemaLoader.cs


示例16: GetTables

 public override TableSchemaCollection GetTables()
 {
     TableSchemaCollection tables = new TableSchemaCollection ();
     Console.WriteLine("getTables");
     using (IPooledDbConnection conn = connectionPool.Request ()) {
         Console.WriteLine("conn:"+conn.ToString());
         MongoDbConnection connection = (MongoDbConnection) conn.DbConnection;
         Console.WriteLine("connection:"+connection.ToString());
         foreach(string colName in connection.getCollections()){
             TableSchema col = new TableSchema(this);
             Console.WriteLine("table add:"+colName);
             col.Name = colName;
             tables.Add(col);
         }
     }
     return tables;
 }
开发者ID:schamane,项目名称:monodevelop-mongodb-provider,代码行数:17,代码来源:MongoDbSchemaProvider.cs


示例17: SimpleColumnTest

        public void SimpleColumnTest()
        {
            var schema = new TableSchema("SimpleColumnTest");

            schema.Columns.AddValueColumn("Col1", typeof(int), 5);
            schema.Columns.AddValueColumn("Col2", typeof(int), 5);
            schema.Columns.AddValueColumn("Col3", typeof(int), 5);
            schema.Columns.AddValueColumn("Col4", typeof(int), 5);

            Expression<Func<Row, object>> func = r =>
                r["Col1"].ToString() + ((int)r["Col2"] % r.Field<int?>("Col3")) + r["Col4"];
            var dep = DependencyParser.GetDependencyTree(schema, func);
            Assert.IsFalse(dep.RequiresDataContext);
            Assert.IsInstanceOfType(dep, typeof(SameRowDependency));

            var srd = (SameRowDependency)dep;
            Assert.IsTrue(schema.Columns.SequenceEqual(srd.DependentColumns.OrderBy(c => c.Name)));
        }
开发者ID:ShomreiTorah,项目名称:Libraries,代码行数:18,代码来源:BasicParsingTest.cs


示例18: GenerateRows

        public static int GenerateRows(StreamWriter writer, TableSchema schema, Locator where, bool hasIfExists)
        {
            TableName tableName = schema.TableName;
            string sql = string.Format("SELECT * FROM {0}", tableName);
            if (where != null)
                sql = string.Format("SELECT * FROM {0} WHERE {1}", tableName, where);

            SqlCmd cmd = new SqlCmd(tableName.Provider, sql);
            TableClause script = new TableClause(schema);

            int count = 0;
            cmd.Read(
                reader =>
                {
                    DataTable schema1 = reader.GetSchemaTable();

                    string[] columns = schema1.AsEnumerable().Select(row => row.Field<string>("ColumnName")).ToArray();
                    object[] values = new object[columns.Length];

                    while (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            reader.GetValues(values);
                            if (hasIfExists)
                                writer.WriteLine(script.IF_NOT_EXISTS_INSERT(columns, values));
                            else
                                writer.WriteLine(script.INSERT(columns, values));

                            count++;
                            if (count % 5000 == 0)
                                writer.WriteLine(TableClause.GO);

                        }
                        reader.NextResult();
                    }
                });

            if (count != 0)
                writer.WriteLine(TableClause.GO);

            return count;
        }
开发者ID:fjiang2,项目名称:sqlcon,代码行数:43,代码来源:Compare.cs


示例19: GetTables

		public override TableSchemaCollection GetTables ()
		{
			TableSchemaCollection tables = new TableSchemaCollection ();
			using (IPooledDbConnection conn = connectionPool.Request ()) {
				using (IDbCommand command = conn.CreateCommand (
					@"SELECT DISTINCT 
						c.relname, 
						n.nspname, 
						u.usename
					FROM 
						pg_class c, 
						pg_namespace n, 
						pg_user u
					WHERE 	
						c.relnamespace = n.oid
						AND c.relowner = u.usesysid
						AND c.relkind='r' 
						AND NOT EXISTS
							(SELECT 1 FROM pg_rewrite r WHERE r.ev_class = c.oid AND r.ev_type = '1')
					ORDER BY relname;")) {
					try {
						using (IDataReader r = command.ExecuteReader()) {
							while (r.Read ()) {
								TableSchema table = new TableSchema (this);
								table.Name = r.GetString (0);
								table.IsSystemTable = table.Name.StartsWith ("pg_") || table.Name.StartsWith ("sql_");
								table.SchemaName = r.GetString (1);
								table.OwnerName = r.GetString (2);
								// TODO: Fill table.Definition
								tables.Add (table);
							}
							r.Close ();
						}
					} catch (Exception e) {
						QueryService.RaiseException (e);
					} finally {
						conn.Release ();
					}
				}
			}
			return tables;
开发者ID:Kalnor,项目名称:monodevelop,代码行数:41,代码来源:NpgsqlSchemaProvider.cs


示例20: DatabaseDifference

        public static string DatabaseDifference(CompareSideType sideType, DatabaseName dname1, DatabaseName dname2, string[] excludedTables)
        {
            TableName[] names = dname1.GetDependencyTableNames();
            excludedTables = excludedTables.Select(row => row.ToUpper()).ToArray();

            StringBuilder builder = new StringBuilder();
            foreach (TableName tableName in names)
            {
                TableName tname1 = tableName;
                TableName tname2 = new TableName(dname2, tableName.SchemaName, tableName.Name);

                TableSchema schema1 = new TableSchema(tname1);
                TableSchema schema2 = new TableSchema(tname2);

                Console.WriteLine(tname1.ShortName);

                if (excludedTables.Contains(tableName.ShortName.ToUpper()))
                {
                    Console.WriteLine("skip to compare data on excluded table {0}", tableName.ShortName);
                    continue;
                }

                if (schema1.PrimaryKeys.Length == 0)
                {
                    Console.WriteLine("undefined primary key");
                    continue;
                }

                if (tname2.Exists())
                {
                    builder.Append(TableDifference(sideType, schema1, schema2, schema1.PrimaryKeys.Keys, new string[] { }));
                }
                else
                {
                    builder.Append(Compare.GenerateRows(schema1, new TableReader(tname1)));
                }

                builder.AppendLine();
            }

            return builder.ToString();
        }
开发者ID:fjiang2,项目名称:sqlcon,代码行数:42,代码来源:Compare.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Tag类代码示例发布时间:2022-05-24
下一篇:
C# TableRow类代码示例发布时间: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