Exemple #1
0
        public void Can_Persist_Enum_To_Text_Column()
        {
            var db = SqlServerNorthwindDatabase();

            using (var tx = db.EnsureInTransaction()) {
                var table = db.Table <Enum.ToTextColumn.Category>();

                var item = new Enum.ToTextColumn.Category {
                    CategoryName = Enum.CategoryEnum.Foo
                };

                table.Add(item);

                Assert.AreEqual(1, table.Count("CategoryID = {0} AND CategoryName = {1}", item.CategoryID, item.CategoryName.ToString()));

                item.CategoryName = Enum.CategoryEnum.Bar;

                table.Update(item);

                Assert.AreEqual(1, table.Count("CategoryID = {0} AND CategoryName = {1}", item.CategoryID, item.CategoryName.ToString()));

                tx.Rollback();
            }
        }
        public void Can_Persist_Enum_To_Text_Column()
        {
            var db = new Database(conn, new AttributeMappingSource().GetModel(typeof(Enum.ToTextColumn.Category)));

            using (var tx = db.EnsureInTransaction()) {
                var table = db.Table <Enum.ToTextColumn.Category>();

                var item = new Enum.ToTextColumn.Category {
                    CategoryName = Enum.CategoryEnum.Foo
                };

                table.Add(item);

                Assert.AreEqual(1, table.Count("CategoryID = {0} AND CategoryName = {1}", item.CategoryID, item.CategoryName.ToString()));

                item.CategoryName = Enum.CategoryEnum.Bar;

                table.Update(item);

                Assert.AreEqual(1, table.Count("CategoryID = {0} AND CategoryName = {1}", item.CategoryID, item.CategoryName.ToString()));

                tx.Rollback();
            }
        }
        public void Can_Persist_Enum_To_Text_Column()
        {
            var db = new Database(conn, new AttributeMappingSource().GetModel(typeof(Enum.ToTextColumn.Category)));

             using (var tx = db.EnsureInTransaction()) {

            var table = db.Table<Enum.ToTextColumn.Category>();

            var item = new Enum.ToTextColumn.Category {
               CategoryName = Enum.CategoryEnum.Foo
            };

            table.Add(item);

            Assert.AreEqual(1, table.Count("CategoryID = {0} AND CategoryName = {1}", item.CategoryID, item.CategoryName.ToString()));

            item.CategoryName = Enum.CategoryEnum.Bar;

            table.Update(item);

            Assert.AreEqual(1, table.Count("CategoryID = {0} AND CategoryName = {1}", item.CategoryID, item.CategoryName.ToString()));

            tx.Rollback();
             }
        }