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


C# OrmTestSession.CreateTable方法代码示例

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


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

示例1: Collate

        public void Collate()
        {
            var obj = new TestObj
                          {
                              CollateDefault = "Alpha ",
                              CollateBinary = "Alpha ",
                              CollateRTrim = "Alpha ",
                              CollateNoCase = "Alpha ",
                          };

            var db = new OrmTestSession();
            db.CreateTable<TestObj>();
            db.Insert(obj);

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateDefault == "Alpha " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "ALPHA " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "ALPHA" select o).Count());

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateBinary == "Alpha " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "ALPHA " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "ALPHA" select o).Count());

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateRTrim == "Alpha " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateRTrim == "ALPHA " select o).Count());
            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateRTrim == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateRTrim == "ALPHA" select o).Count());

            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateNoCase == "Alpha " select o).Count());
            Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateNoCase == "ALPHA " select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateNoCase == "Alpha" select o).Count());
            Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateNoCase == "ALPHA" select o).Count());
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:34,代码来源:CollateTest.cs

示例2: CreateInsertDrop

        public void CreateInsertDrop()
        {
            var db = new OrmTestSession();

            db.CreateTable<Product>();

            db.Insert(new Product
                          {
                              Name = "Hello",
                              Price = 16,
                          });

            int n = db.Table<Product>().Count();

            Assert.AreEqual(1, n);

            db.DropTable<Product>();

            try
            {
                // Should throw SqliteException
                db.Table<Product>().Count();

                Assert.Fail("Expeced 'table does not exist' error.");
            }
            catch (SqliteException)
            {
            }
            catch
            {
                Assert.Fail();
            }
        }
开发者ID:distributedlife,项目名称:Mono.Data.Sqlite.Orm,代码行数:33,代码来源:DropTableTest.cs

示例3: Skip

        public void Skip()
        {
            var db = new OrmTestSession();
			db.CreateTable<TestObj>();
            const int n = 100;

            IEnumerable<TestObj> cq = from i in Enumerable.Range(1, n)
                                      select new TestObj
                                                 {
                                                     Order = i
                                                 };
            TestObj[] objs = cq.ToArray();

            int numIn = db.InsertAll(objs);
            Assert.AreEqual(numIn, n, "Num inserted must = num objects");

            TableQuery<TestObj> q = from o in db.Table<TestObj>()
                                    orderby o.Order
                                    select o;

            TableQuery<TestObj> qs1 = q.Skip(1);
            List<TestObj> s1 = qs1.ToList();
            Assert.AreEqual(n - 1, s1.Count);
            Assert.AreEqual(2, s1[0].Order);

            TableQuery<TestObj> qs5 = q.Skip(5);
            List<TestObj> s5 = qs5.ToList();
            Assert.AreEqual(n - 5, s5.Count);
            Assert.AreEqual(6, s5[0].Order);
        }
开发者ID:distributedlife,项目名称:Mono.Data.Sqlite.Orm,代码行数:30,代码来源:SkipTest.cs

示例4: TestBoolean

        public void TestBoolean()
        {
            var db = new OrmTestSession();
            db.CreateTable<Vo>();

            for (int i = 0; i < 10; i++)
            {
                db.Insert(new Vo {Flag = (i%3 == 0), Text = String.Format("VO{0}", i)});
            }

            // count vo which flag is true            
            Assert.AreEqual(4, CountWithFlag(db, true));
            Assert.AreEqual(6, CountWithFlag(db, false));

            Debug.WriteLine("VO with true flag:");
            foreach (Vo vo in db.Query<Vo>("SELECT * FROM VO Where Flag = ?", true))
            {
                Debug.WriteLine(vo.ToString());
            }

            Debug.WriteLine("VO with false flag:");
            foreach (Vo vo in db.Query<Vo>("SELECT * FROM VO Where Flag = ?", false))
            {
                Debug.WriteLine(vo.ToString());
            }
        }
开发者ID:distributedlife,项目名称:Mono.Data.Sqlite.Orm,代码行数:26,代码来源:BooleanTest.cs

示例5: ClearTableTest

        public void ClearTableTest()
        {
            // setup
            var db = new OrmTestSession();
            db.CreateTable<Product>();

            // insert
            db.Insert(new Product { Name = "Hello", Price = 16, });
            db.Insert(new Product { Name = "Hello", Price = 16, });

            // confirm
            Assert.AreEqual(2, db.Table<Product>().Count());
            db.Get<Product>(1);

            // clear
            Assert.AreEqual(2, db.ClearTable<Product>());

            // confirm
            Assert.AreEqual(0, db.Table<Product>().Count());

            // insert
            db.Insert(new Product { Name = "Hello", Price = 16, });

            // confirm that the Ids have not reset
            Assert.AreEqual(1, db.Table<Product>().Count());
            db.Get<Product>(3);
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:27,代码来源:DropTableTest.cs

示例6: CreateUnknownColumnType

 public void CreateUnknownColumnType()
 {
     using (var db = new OrmTestSession())
     {
         ExceptionAssert.Throws<NotSupportedException>(() => db.CreateTable<UnknownColumnType>());
     }
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:7,代码来源:CreateTableTest.cs

示例7: DropTableUsingSqlString

 public void DropTableUsingSqlString()
 {
     var db = new OrmTestSession();
     
     db.CreateTable<Product>();
     
     var results = db.Execute("DROP TABLE IF EXISTS Product;");
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:8,代码来源:DropTableTest.cs

示例8: EnsureSimpleTableExistsUsingQuery

 public void EnsureSimpleTableExistsUsingQuery()
 {
     using (var db = new OrmTestSession())
     {
         db.CreateTable<SimpleTable>();
         Assert.AreEqual(0, db.ExecuteScalar<int>("SELECT COUNT(*) FROM [SimpleTable];"));
     }
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:8,代码来源:CreateVirtualTableTest.cs

示例9: EnsureSimpleTableExistsUsingTableExists

 public void EnsureSimpleTableExistsUsingTableExists()
 {
     using (var db = new OrmTestSession())
     {
         db.CreateTable<SimpleTable>();
         Assert.IsTrue(db.TableExists<SimpleTable>());
     }
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:8,代码来源:CreateVirtualTableTest.cs

示例10: MergeTest

 public void MergeTest()
 {
     using (var db = new OrmTestSession())
     {
         db.CreateTable<SimpleTable>();
         db.Insert(new SimpleTable { Name = RandomString() });
         db.Merge<SimpleTable>();
     }
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:9,代码来源:FTSSpecialCommandsTest.cs

示例11: RunMergeUntilOptimalTest

 public void RunMergeUntilOptimalTest()
 {
     using (var db = new OrmTestSession())
     {
         db.CreateTable<SimpleTable>();
         db.Insert(new SimpleTable { Name = RandomString() });
         db.RunMergeUntilOptimal<SimpleTable>();
     }
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:9,代码来源:FTSSpecialCommandsTest.cs

示例12: CreateInstanceHookTest

 public void CreateInstanceHookTest()
 {
     var db = new OrmTestSession();
     db.InstanceCreated += InstanceCreated;
     db.CreateTable<HookTestTable>();
     db.Insert(new HookTestTable { Text = InsertedTest });
     var got = db.Get<HookTestTable>(1);
     Assert.AreEqual(ReplacedText, got.Text);
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:9,代码来源:HooksTest.cs

示例13: IntegrityCheckTest

 public void IntegrityCheckTest()
 {
     using (var db = new OrmTestSession())
     {
         db.CreateTable<SimpleTable>();
         db.Insert(new SimpleTable { Name = RandomString() });
         db.IntegrityCheck<SimpleTable>();
     }
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:9,代码来源:FTSSpecialCommandsTest.cs

示例14: CreateInstanceHookTestNonGeneric

 public void CreateInstanceHookTestNonGeneric()
 {
     var db = new OrmTestSession();
     db.InstanceCreated += InstanceCreated;
     db.CreateTable<HookTestTable>();
     db.Insert(new HookTestTable { Text = InsertedTest });
     var got = db.Get(typeof(HookTestTable), 1);
     Assert.AreEqual(ReplacedText, ((HookTestTable)got).Text);
 }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:9,代码来源:HooksTest.cs

示例15: CreateThem

        public void CreateThem()
        {
            var db = new OrmTestSession();
            db.CreateTable<Product>();
            db.CreateTable<OrderLine>();

            var foo = new Product { Name = "Foo", Price = 10.0m };
            var bar = new Product { Name = "Bar", Price = 0.10m };
            db.Insert(foo);
            db.Insert(bar);
            db.Insert(new OrderLine { ProductId = foo.Id, Quantity = 6, UnitPrice = 10.01m });
            db.Insert(new OrderLine { ProductId = foo.Id, Quantity = 3, UnitPrice = 0.02m });
            db.Insert(new OrderLine { ProductId = bar.Id, Quantity = 9, UnitPrice = 100.01m });

            OrderLine[] lines = foo.OrderLines;

            Assert.AreEqual(lines.Length, 2, "Has 2 order lines");
            Assert.AreEqual(foo.Connection, db, "foo.Connection was set");
            Assert.AreEqual(lines[0].Connection, db, "lines[0].Connection was set");
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:20,代码来源:ConnectionTrackingTest.cs


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