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


C# OrmTestSession.Close方法代码示例

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


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

示例1: InterfaceTest

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

            db.CreateTable<Product>();

            var obj1 = new Product { Name = "Some Cool Name" };

            int numIn1 = db.Insert(obj1);
            Assert.AreEqual(1, numIn1);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:13,代码来源:InterfaceTests.cs

示例2: InsertALotPlain

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

            SqliteSession.Trace = false;

            db.CreateTable<TestObjPlain>();

            const int n = 10000;
            IEnumerable<TestObjPlain> q = Enumerable.Range(1, n).Select(i => new TestObjPlain { Text = "I am" });
            TestObjPlain[] objs = q.ToArray();
            int numIn = db.InsertAll(objs);

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

            TestObjPlain[] inObjs = db.Table<TestObjPlain>().ToArray();

            foreach (TestObjPlain t in inObjs)
            {
                Assert.AreEqual("I am", t.Text);
            }

            int numCount = db.Table<TestObjPlain>().Count();

            Assert.AreEqual(numCount, n, "Num counted must = num objects");

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:28,代码来源:InsertTest.cs

示例3: InsertTwoTimes

        public void InsertTwoTimes()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj>();

            var obj1 = new TestObj { Text = "GLaDOS loves testing!" };
            var obj2 = new TestObj { Text = "Keep testing, just keep testing" };

            int numIn1 = db.Insert(obj1);
            int numIn2 = db.Insert(obj2);
            Assert.AreEqual(1, numIn1);
            Assert.AreEqual(1, numIn2);

            List<TestObj> result = db.Query<TestObj>("select * from TestObj").ToList();
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(obj1.Text, result[0].Text);
            Assert.AreEqual(obj2.Text, result[1].Text);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:20,代码来源:InsertTest.cs

示例4: InsertWithExtra

        public void InsertWithExtra()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj2>();

            var obj1 = new TestObj2 { Id = 1, Text = "GLaDOS loves testing!" };
            var obj2 = new TestObj2 { Id = 1, Text = "Keep testing, just keep testing" };
            var obj3 = new TestObj2 { Id = 1, Text = "Done testing" };

            db.Insert(obj1);

            // "Expected unique constraint violation"
            ExceptionAssert.Throws<SqliteException>(() => db.Insert(obj2));

            db.Insert(obj2, ConflictResolution.Replace);

            // "Expected unique constraint violation"
            ExceptionAssert.Throws<SqliteException>(() => db.Insert(obj3));

            db.Insert(obj3, ConflictResolution.Ignore);

            List<TestObj> result = db.Query<TestObj>("select * from TestObj2").ToList();
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(obj2.Text, result.First().Text);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:27,代码来源:InsertTest.cs

示例5: InsertIntoTwoTables

        public void InsertIntoTwoTables()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj>();
            db.CreateTable<TestObj2>();

            var obj1 = new TestObj { Text = "GLaDOS loves testing!" };
            var obj2 = new TestObj2 { Text = "Keep testing, just keep testing" };

            int numIn1 = db.Insert(obj1);
            Assert.AreEqual(1, numIn1);
            int numIn2 = db.Insert(obj2);
            Assert.AreEqual(1, numIn2);

            List<TestObj> result1 = db.Table<TestObj>().ToList();
            Assert.AreEqual(numIn1, result1.Count);
            Assert.AreEqual(obj1.Text, result1.First().Text);

            List<TestObj> result2 = db.Query<TestObj>("select * from TestObj2").ToList();
            Assert.AreEqual(numIn2, result2.Count);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:23,代码来源:InsertTest.cs

示例6: InsertObjectWithValueInPrimaryKey

        public void InsertObjectWithValueInPrimaryKey()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj2>();

            var obj2 = new TestObj2 {Id = 5, Text = "Old"};

            int numIn1 = db.Insert(obj2);
            Assert.AreEqual(1, numIn1);

            var result = db.Table<TestObj2>().Single(i => i.Id == 5);
            Assert.AreEqual("Old", result.Text);

            result.Text = "New";
            var upd = db.Update(result);

            result = db.Table<TestObj2>().Single(i => i.Id == 5);
            Assert.AreEqual("New", result.Text);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:21,代码来源:InsertTest.cs

示例7: InsertGuid

        public void InsertGuid()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObjDateTime>();

            var obj2 = new TestObjDateTime { Guid = Guid.NewGuid() };

            int numIn1 = db.Insert(obj2);
            Assert.AreEqual(1, numIn1);

            TestObjDateTime result = db.Table<TestObjDateTime>().First(i => i.Id == obj2.Id);
            Assert.AreEqual(obj2.Guid, result.Guid);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:15,代码来源:InsertTest.cs

示例8: InsertDateTime

        public void InsertDateTime()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObjDateTime>();

            DateTime date = DateTime.Now;
            var obj1 = new TestObjDateTime { TheDate = date };

            int numIn1 = db.Insert(obj1);
            Assert.AreEqual(1, numIn1);

            TestObjDateTime result = db.Table<TestObjDateTime>().First();
            Assert.AreEqual(date, result.TheDate);
            Assert.AreEqual(obj1.TheDate, result.TheDate);

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:17,代码来源:InsertTest.cs

示例9: InsertALot

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

            SqliteSession.Trace = false;

            db.CreateTable<TestObj>();

            const int n = 10000;
            IEnumerable<TestObj> q = Enumerable.Range(1, n).Select(i => new TestObj { Text = "I am" });
            TestObj[] objs = q.ToArray();
            int numIn = db.InsertAll(objs);

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

            TestObj[] inObjs = db.Table<TestObj>().ToArray();

            for (int i = 0; i < inObjs.Length; i++)
            {
                Assert.AreEqual(i + 1, objs[i].Id);
                Assert.AreEqual(i + 1, inObjs[i].Id);
                Assert.AreEqual("I am", inObjs[i].Text);
            }

            int numCount = db.Table<TestObj>().Count();

            Assert.AreEqual(numCount, n, "Num counted must = num objects");

            db.Close();
        }
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm,代码行数:30,代码来源:InsertTest.cs


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