예제 #1
0
        public void TestInsertUserClassMuti()
        {
            var db = new NLORMMSSQLDb(ConnectionString);

            db.CreateTable <TestClassUser>();

            var insertList = new List <TestClassUser>();

            for (int i = 0; i < 30; i++)
            {
                var testObj = new TestClassUser {
                    ID         = i, Name = "Name " + i,
                    CreateTime = DateTime.Now.AddDays(i)
                };
                insertList.Add(testObj);
            }
            foreach (TestClassUser user in insertList)
            {
                db.Insert <TestClassUser>(user);
            }

            var selLis = db.Query <TestClassUser>();

            Assert.AreEqual(selLis.Count(), 30);
        }
예제 #2
0
        public void TestQueryMethod2()
        {
            INLORMDb db = new NLORMMSSQLDb(ConnectionString);

            db.CreateTable <TestClass01>();
            db.Insert <TestClass01>(new TestClass01()
            {
                ID = @"11", name = @"albert"
            });
            db.Insert <TestClass01>(new TestClass01()
            {
                ID = @"22", name = @"star"
            });
            var result = db.FilterBy(FilterType.EQUAL_AND, new { name = "albert" }).Query <TestClass01>();

            Assert.AreEqual(1, result.Count());
        }
예제 #3
0
        public void TestInsertAlotItems()
        {
            INLORMDb db = new NLORMMSSQLDb(ConnectionString);

            db.CreateTable <TestClass01>();
            for (int i = 0; i < 1000; i++)
            {
                db.Insert <TestClass01>(new TestClass01()
                {
                    ID = @"0" + i.ToString(), name = @"00" + i.ToString()
                });
            }

            var result = db.Query <TestClass01>(@"SELECT * FROM TestClass01");

            Assert.AreEqual(result.Count(), 1000);
        }
예제 #4
0
        public void TestUpdateOneRow()
        {
            var db     = new NLORMMSSQLDb(connectionString);
            var oldobj = new TestClassOne()
            {
                Id = "sssss", income = 20
            };
            var newobj = new TestClassOne {
                Id = "sssss", income = 100
            };

            db.CreateTable <TestClassOne>();
            db.Insert <TestClassOne>(oldobj);
            int i     = db.FilterBy(FilterType.EQUAL_AND, new { Id = "sssss" }).Update <TestClassOne>(newobj);
            var items = db.FilterBy(FilterType.EQUAL_AND, new { Id = "sssss" }).Query <TestClassOne>().First();

            Assert.AreEqual(100, items.income);
        }
예제 #5
0
        public void TestTransactionCommit()
        {
            var db = new NLORMMSSQLDb(ConnectionString);

            db.CreateTable <TestClassUser>();
            var trans   = db.BeginTransaction();
            var testObj = new TestClassUser();

            testObj.ID         = 1;
            testObj.Name       = "Name " + 1;
            testObj.CreateTime = DateTime.Now;
            db.Insert <TestClassUser>(testObj);
            trans.Commit();
            db.Close();
            db = new NLORMMSSQLDb(ConnectionString);
            var selLis = db.Query <TestClassUser>();

            Assert.AreEqual(selLis.Count(), 1);
        }
예제 #6
0
        public void TestInsertUserClass()
        {
            var db = new NLORMMSSQLDb(ConnectionString);

            db.CreateTable <TestClassUser>();

            var testObj = new TestClassUser();

            testObj.ID         = 1;
            testObj.Name       = "Name " + 1;
            testObj.CreateTime = DateTime.Now;

            db.Insert <TestClassUser>(testObj);
            var selLis = db.Query <TestClassUser>();

            Assert.AreEqual(selLis.Count(), 1);
            var selUser = selLis.ToArray()[0];

            Assert.AreEqual(testObj.ID, selUser.ID);
            Assert.AreEqual(testObj.Name, selUser.Name);
            //Assert.AreEqual(testObj.CreateTime,selUser.CreateTime);
        }
예제 #7
0
        public void TestQueryMethod2()
        {
            INLORMDb db = new NLORMMSSQLDb( constr);
            db.CreateTable<TestClass01>();
            db.Insert<TestClass01>( new TestClass01(){ ID = @"11", name = @"albert"});
            db.Insert<TestClass01>( new TestClass01(){ ID = @"22", name = @"star"});
            var result = db.FilterBy( FilterType.EQUAL_AND, new { name = "albert"} ).Query<TestClass01>();

            Assert.AreEqual( 1, result.Count() );
        }
예제 #8
0
        public void TestInsertAlotItems()
        {
            INLORMDb db = new NLORMMSSQLDb( constr);
            db.CreateTable<TestClass01>();
            for ( int i = 0; i < 1000; i++)
            {
                db.Insert<TestClass01>( new TestClass01(){ ID = @"0" + i.ToString(), name = @"00" + i.ToString() });
            }

            var result = db.Query<TestClass01>(@"SELECT * FROM TestClass01");
            Assert.AreEqual( result.Count(), 1000);
        }