当前位置: 首页>>代码示例>>C#>>正文


C# Schema.GetTable方法代码示例

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


在下文中一共展示了Schema.GetTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_Create_Tables_With_Schema_In_Sqlite

        public void Can_Create_Tables_With_Schema_In_Sqlite()
        {
            OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();

            using (IDbConnection db = "User=SYSDBA;Password=masterkey;Database=ormlite-tests.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
            {
                db.CreateTable<User>(true);

                var schema  =  new Schema(){Connection= db};
				var table = schema.GetTable("Security_Users".ToUpper());                    
				
                //sqlite dialect should just concatenate the schema and table name to create a unique table name
                Assert.That( ! (table == null) );
            }
        }
开发者ID:yeurch,项目名称:ServiceStack.OrmLite,代码行数:15,代码来源:SchemaUseCase.cs

示例2: NonAutoDispose_ConnectionFactory_delete_and_drop

        public void NonAutoDispose_ConnectionFactory_delete_and_drop()
        {
            var factory = new OrmLiteConnectionFactory("User=SYSDBA;Password=masterkey;Database=ormlite-tests.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;", false);

            using (var db = factory.OpenDbConnection())
            {
                db.DeleteAll<Shipper>();
                Assert.That(db.Select<Shipper>(), Has.Count.EqualTo(0));
            }

            using (var db = factory.OpenDbConnection())
            {
                db.DropTable<Shipper>();
                var schema = new Schema {
                    Connection = db,
                };

                Assert.That(schema.GetTable("Shippers".ToUpper()) == null);
            }
        }
开发者ID:sami1971,项目名称:NServiceKit.OrmLite,代码行数:20,代码来源:OrmLiteConnectionFactoryTests.cs

示例3: GetTable

        public void GetTable()
        {
            Schema schema = new Schema();
            schema.AddSchema(new SchemaDefinition("dbo"));

            schema.AddTable(new TableDefinition("Foo", schema.Schemas[0]));
            schema.AddTable(new TableDefinition("baR"));

            Assert.IsNull(schema.GetTable("Foo"));

            Assert.AreSame(schema.Tables[0], schema.GetTable("dbo", "Foo"));
            Assert.AreSame(schema.Tables[0], schema.GetTable("DBO", "FOO"));
            Assert.AreSame(schema.Tables[0], schema.GetTable(schema.Schemas[0], "FOO"));

            Assert.AreSame(schema.Tables[1], schema.GetTable("BaR"));
            Assert.AreSame(schema.Tables[1], schema.GetTable("baR"));

            Assert.IsNull(schema.GetTable("Qux"));
        }
开发者ID:hoonsbara,项目名称:octalforty-wizardby,代码行数:19,代码来源:SchemaTestFixture.cs

示例4: GetTableDefinitions

        /// <summary>
        /// When overriden in derived class, retrieves a collection of all
        /// tables, their columns and primary keys in the database defined by the 
        /// <see cref="connectionString"/>.
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="databaseSchema"></param>
        /// <returns></returns>
        protected override void GetTableDefinitions(string connectionString, Schema databaseSchema)
        {
            base.GetTableDefinitions(connectionString, databaseSchema);
            FixupColumnLengths(databaseSchema);
            FixupColumnScaleAndPrecision(databaseSchema);
            
            //
            // Identities
            ExecuteReader(connectionString, @"select table_schema, table_name, column_name
	from information_schema.columns
where columnproperty(object_id(quotename(table_schema) + '.' + quotename(table_name)), column_name, 'IsIdentity') = 1", 
                delegate(IDataReader dr)
                    {
                        string schemaName = As<string>(dr, "table_schema");
                        string tableName = As<string>(dr, "table_name");

                        ITableDefinition table = databaseSchema.GetTable(schemaName, tableName);
                        if(table == null)
                            return;

                        IColumnDefinition identityColumn = table.GetColumn(As<string>(dr, "column_name"));
                        identityColumn.Identity = true;
                    });
        }
开发者ID:hoonsbara,项目名称:octalforty-wizardby,代码行数:32,代码来源:SqlServer2000SchemaProvider.cs

示例5: Main

		public static void Main (string[] args)
		{
			OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();
			
			
			using (IDbConnection db =
			       "User=SYSDBA;Password=masterkey;Database=employee.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
			{
			
				Schema fbd= new Schema(){
					Connection = db
				};
		
				Console.WriteLine("--------TABLES-------------");
				
				var tables = fbd.Tables;
				
				foreach(Table t in tables){
					Console.WriteLine(t.Name);
				}
								
				Console.WriteLine("-------users's owner--------------");
				
				
				Table t1 = fbd.GetTable("USERS");
				Console.WriteLine(t1.Owner);
				
				Console.WriteLine ("---------user's columns ----------------");
				
				var Columns = fbd.GetColumns("USERS");
					
				foreach(Column cl in Columns){
					Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} ",
					                  cl.Name,cl.Position, cl.Nullable, cl.Length, cl.DbType, cl.NetType, cl.Sequence);	
				}
				
				Console.WriteLine("--------------------------------------------");
				
				Console.WriteLine("EMPLOYEE's Columns ");
				
				Columns = fbd.GetColumns("EMPLOYEE");
				
				foreach(Column cl in Columns){
					Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} -- Computed {7} ",
					                  cl.Name,cl.Position, cl.Nullable, cl.Length, cl.DbType,
					                  cl.NetType, cl.Sequence,cl.IsComputed);	
				}
				
				Columns = fbd.GetColumns("COMPANY");
				
				foreach(Column cl in Columns){
					Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} ",
					                  cl.Name,cl.Position, cl.Nullable, cl.Length, cl.DbType, cl.NetType, cl.Sequence);	
				}
				
				Console.WriteLine("--------------------------------------------");
				
				Console.WriteLine("-----------------Procedure---------------------------");
				
				Console.WriteLine ("----- ADD_EMP_PROJ ----");
				
				Procedure p = fbd.GetProcedure("ADD_EMP_PROJ");
				Console.WriteLine("p.Name {0} p.Owner {1} p.Inputs {2} p.Outputs {3} p.Type {4}",
				                  p.Name, p.Owner, p.Inputs, p.Outputs, p.Type);
				
				var parameters = fbd.GetParameters(p);
				foreach( var par in parameters){
					Console.WriteLine("p.ProcedureName {0} p.Name {1} p.Position {2} p.ParameterType {3} p.DbType {4} p.NetType {5}",
					                  par.ProcedureName, par.Name, par.Position, par.Direction, par.DbType, par.NetType);
				}
				
				
				Console.WriteLine ("----- ALL_LANGS ----");
				p = fbd.GetProcedure("ALL_LANGS");
				Console.WriteLine("p.Name {0} p.Owner {1} p.Inputs {2} p.Outputs {3} p.Type {4}",
				                  p.Name, p.Owner, p.Inputs, p.Outputs, p.Type);
				
				
				parameters = fbd.GetParameters(p);
				
				parameters = fbd.GetParameters(p);
				foreach( var par in parameters){
					Console.WriteLine("p.ProcedureName {0} p.Name {1} p.Position {2} p.ParameterType {3} p.DbType {4} p.NetType {5}",
					                  par.ProcedureName, par.Name, par.Position, par.Direction, par.DbType, par.NetType);
				}
				
				
				ClassWriter cw = new ClassWriter(){
					Schema=fbd,
				};
				
				cw.WriteClass( new Table(){Name="EMPLOYEE"} );
				
				
				Console.WriteLine("This is The End my friend");
			
			//DTOGenerator
				
			}
			
//.........这里部分代码省略.........
开发者ID:paladincoder,项目名称:ServiceStack.OrmLite,代码行数:101,代码来源:Main.cs


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