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


C# Database.CreateTable方法代码示例

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


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

示例1: UpdateDatabase

        private static void UpdateDatabase(Database database)
        {
            database.CreateTable<Schedule>(false);
            database.CreateTable<Log>(false);

            database.Execute(@"
            IF NOT EXISTS(
            SELECT *
            FROM   INFORMATION_SCHEMA.COLUMNS
            WHERE  TABLE_NAME = 'uScheduler_Schedules'
            AND COLUMN_NAME = 'Headers')
            ALTER TABLE dbo.uScheduler_Schedules
            ADD [Headers] NTEXT"
            );

            database.Execute(@"
            IF NOT EXISTS(
            SELECT *
            FROM   INFORMATION_SCHEMA.COLUMNS
            WHERE  TABLE_NAME = 'uScheduler_Log'
            AND COLUMN_NAME = 'MachineName')
            ALTER TABLE dbo.uScheduler_Log
            ADD [MachineName] NVARCHAR(100)"
            );
        }
开发者ID:AffinityID,项目名称:uScheduler,代码行数:25,代码来源:SchedulerApplication.cs

示例2: Execute

        public void Execute(Database database)
        {
            Table table = database.CreateTable(this.name);

            foreach (Column column in this.columns)
                table.AddColumn(column);
        }
开发者ID:ajlopez,项目名称:AjBase,代码行数:7,代码来源:CreateTableCommand.cs

示例3: Create

        private static void Create(Database db)
        {
            const string TABLE = "table";
            const string COLUMN = "column";
            const string COLUMN2 = "column2";
            const string COLUMN3 = "column3";
            const string COLUMN4 = "int_column";
            const string COLUMN5 = "code";

            using (var tx = db.Session.BeginTransaction())
            using (var table = db.CreateTable(TABLE))
            {
                var col1 = table.AddColumn<string>(COLUMN,
                    new ColumnOptions { Encoding = Encoding.Unicode, Length = 200 });

                var col2 = table.AddColumn<string>(COLUMN2,
                    new ColumnOptions { Encoding = Encoding.Unicode, Length = 200 });

                table.AddColumn<string>(COLUMN3,
                    new ColumnOptions { Encoding = Encoding.Unicode, Length = 200 });

                var col4 = table.AddColumn<int>(COLUMN4, new ColumnOptions { ColumnType = typeof(int), IsNullable = false});

                var col5 = table.AddColumn<string>(COLUMN5,
                    new ColumnOptions { Encoding = Encoding.Unicode, Length = 200 });

                table.AddSearchIndex(COLUMN, col1);
                table.AddSearchIndex(COLUMN2, col2);
                table.AddSearchIndex(COLUMN4, col4);
                table.AddSearchIndex(COLUMN5, col5);

                tx.Commit();
            }
        }
开发者ID:meowthsli,项目名称:Esentery,代码行数:34,代码来源:IntegrationTests.cs

示例4: InitializeDatabaseSchema

        /// <summary>
        /// The initialize database schema.
        /// </summary>
        /// <param name="database">
        /// The database.
        /// </param>
        /// <param name="orderedTables">
        /// The ordered tables.
        /// </param>
        /// <param name="migrationName">
        /// The migration name.
        /// </param>
        internal static void InitializeDatabaseSchema(Database database, Dictionary<int, Type> orderedTables, string migrationName)
        {
            LogHelper.Info<DatabaseSchemaHelper>(string.Format("Start InstallDataSchema {0}", migrationName));

            foreach (var item in orderedTables.OrderBy(x => x.Key))
            {
                database.CreateTable(false, item.Value);
            }
        }
开发者ID:ProNotion,项目名称:Merchello,代码行数:21,代码来源:DatabaseSchemaHelper.cs

示例5: SetUpTable

 public void SetUpTable()
 {
     this.engine = new Engine();
     this.database = this.engine.CreateDatabase("Sales");
     this.table = database.CreateTable("Employees");
     this.table.AddColumn(new Column("FirstName"));
     this.table.AddColumn(new Column("LastName"));
     this.table.AddRow(new object[] { "John", "Smith" });
     this.table.AddRow(new object[] { "Adam", "Jones" });
     this.table.AddRow(new object[] { "Alice", "Stuart" });
     Engine.Current = this.engine;
 }
开发者ID:ajlopez,项目名称:AjBase,代码行数:12,代码来源:AjBaseCommandTests.cs

示例6: CreateStorage

     void CreateStorage()
     {
         storage = StorageFactory.Instance.CreateStorage();
     	// create in-memory storage
     	storage.Open(databasePath, 0);
         db = new Database(storage, true);
         db.BeginTransaction();
     	if (db.CreateTable(typeof(EmployeeTable))){
 			Results.Text = "Table Created";
 		} else {
 			Results.Text = "Table Already Exits";
 		}
     	db.CommitTransaction();        	
     }
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:14,代码来源:MainPage.xaml.cs

示例7: RunTest

        public async Task RunTest()
        {
            var exists = await Database.DoesDatabaseExistsAsync(DatabaseName);

            if (!exists)
            {
                database = await Database.CreateDatabaseAsync(DatabaseName);

                database.CreateTable<SpikeDBObject>();

                var table = await database.Table<SpikeDBObject>();

                await database.SaveAsync();

                // Does this order matter
                Comics = table;
            }
            else
            {
                database = await Database.OpenDatabaseAsync(DatabaseName, true, StorageLocation.Local);

                Comics = await database.Table<SpikeDBObject>();
            }
        }
开发者ID:DavidBasarab,项目名称:FatCatComics,代码行数:24,代码来源:DatabaseTestStuff.cs

示例8: Main

    static public void Main(String[] args) 
    {	
        Storage storage = StorageFactory.Instance.CreateStorage();
        storage.Open("testssd2.dbs");
        Database db = new Database(storage);

        db.CreateTable(typeof(Supplier));
        db.CreateIndex(typeof(Supplier), "name", true);
        db.CreateTable(typeof(Detail));
        db.CreateIndex(typeof(Detail), "id", true);
        db.CreateTable(typeof(Shipment));

        Query supplierQuery = db.Prepare(typeof(Supplier), "name like ?");
        Query detailQuery = db.Prepare(typeof(Detail), "id like ?");


        while (true) 
        { 
            try 
            { 
                switch ((int)inputLong("-------------------------------------\n" + 
                    "Menu:\n" + 
                    "1. Add supplier\n" + 
                    "2. Add detail\n" + 
                    "3. Add shipment\n" + 
                    "4. List of suppliers\n" + 
                    "5. List of details\n" + 
                    "6. Suppliers of detail\n" + 
                    "7. Details shipped by supplier\n" + 
                    "8. Find shipments for the particular date\n" + 
                    "9. Exit\n\n>>"))
                {
                    case 1:
                    {
                        Supplier supplier = new Supplier();
                        supplier.name = input("Supplier name: ");
                        supplier.location = input("Supplier location: ");
                        supplier.shipments = storage.CreateLink();
                        db.AddRecord(supplier);
                        storage.Commit();
                        continue;
                    }
                    case 2:
                    {
                        Detail detail = new Detail();
                        detail.id = input("Detail id: ");
                        detail.weight = (float)inputDouble("Detail weight: ");
                        detail.shipments = storage.CreateLink();
                        db.AddRecord(detail);
                        storage.Commit();
                        continue;
                    }
                    case 3:
                    {
                        Shipment shipment = null;
                        foreach (Supplier supplier in db.Select(typeof(Supplier), "name='" + input("Supplier name: ") + "'"))
                        {
                            foreach (Detail detail in db.Select(typeof(Detail), "id='" + input("Detail ID: ") + "'"))
                            {
                                shipment = new Shipment();
                                shipment.quantity = (int)inputLong("Shipment quantity: ");
                                shipment.price = inputLong("Shipment price: ");
                                shipment.date = DateTime.Parse(input("Date: "));
                                shipment.detail = detail;
                                shipment.supplier = supplier;
                                detail.shipments.Add(shipment);
                                supplier.shipments.Add(shipment);
                                db.AddRecord(shipment);
                                storage.Commit();
                            }
                        }
                        if (shipment == null) 
                        { 
                            Console.WriteLine("Supplier+Detail not found");
                        }
                        continue;
                    }
                    case 4:
                        foreach (Supplier supplier in db.GetRecords(typeof(Supplier))) 
                        { 
                            Console.WriteLine("Supplier name: " + supplier.name + ", supplier.location: " + supplier.location);
                        }
                        break;
                    case 5:
                        foreach (Detail detail in db.GetRecords(typeof(Detail))) 
                        {
                            Console.WriteLine("Detail ID: " + detail.id + ", detail.weight: " + detail.weight);
                        }
                        break;
                    case 6:
                    {
                        Hashtable result = new Hashtable();
                        detailQuery[1] = input("Detail ID: ");
                        foreach (Detail detail in detailQuery.Execute(db.GetRecords(typeof(Detail))))
                        {
                            foreach (Shipment shipment in detail.shipments)
                            {
                                result[shipment.supplier] = shipment;
                            }
                        }
//.........这里部分代码省略.........
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:101,代码来源:JsqlSSD.cs


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