當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。