Beispiel #1
0
        public void TestTableNameForCrud()
        {
            DbEntry.From <compTableName>().Where(p => p.Name == "tom").Select();
            AssertSql(@"SELECT [Id],[Name] FROM [tom].[test_table] WHERE [Name] = @Name_0;
<Text><60>(@Name_0=tom:String)");

            var c = new compTableName {
                Name = "tom"
            };

            DbEntry.Insert(c);
            AssertSql(@"INSERT INTO [tom].[test_table] ([Name]) VALUES (@Name_0);
SELECT LAST_INSERT_ROWID();
<Text><30>(@Name_0=tom:String)");

            c.Id   = 2;
            c.Name = "jerry";
            DbEntry.Update(c);
            AssertSql(@"UPDATE [tom].[test_table] SET [Name]=@Name_0  WHERE [Id] = @Id_1;
<Text><30>(@Name_0=jerry:String,@Id_1=2:Int64)");

            DbEntry.Delete(c);
            AssertSql(@"DELETE FROM [tom].[test_table] WHERE [Id] = @Id_0;
<Text><30>(@Id_0=2:Int64)");
        }
Beispiel #2
0
        public void TestSavedOnForPartialUpdate()
        {
            var o = DateTable4.AsLoad(1, "tom");

            DbEntry.Update(o);
            Assert.AreEqual("UPDATE [DateTable] SET [Name]=@Name_0,[SavedOn]=DATETIME(CURRENT_TIMESTAMP, 'localtime')  WHERE [Id] = @Id_1;\n<Text><30>(@Name_0=tom:String,@Id_1=1:Int64)", StaticRecorder.LastMessage);
        }
Beispiel #3
0
        public void Test3()
        {
            DbEntry.Delete <Unit>(WhereCondition.EmptyCondition);

            Unit u = DynamicObject.NewObject <Unit>("00001");

            u.Name      = "吨";
            u.CreatedBy = "Jacky";
            u.UpdatedBy = "Admin";

            DbEntry.Save(u);
            var u1 = DbEntry.GetObject <Unit>(u.UnitId);

            Assert.AreEqual(u1.UnitId, u.UnitId);

            u1.Name = "M3";
            DbEntry.Update(u1);

            Unit u2 = DynamicObject.NewObject <Unit>("00002");

            u2.Init("M3", "Admin");
            Assert.AreEqual("M3", u2.Name);
            DbEntry.Save(u2);

            Assert.AreEqual(2, DbEntry.From <Unit>().Where(WhereCondition.EmptyCondition).GetCount());
        }
Beispiel #4
0
        public void Test2()
        {
            //Role r = new Role() {
            //    Name = "Jacky",
            //    CreatedBy = "Admin",
            //    UpdatedBy = "Admin"
            //};
            Role r = Role.New();

            r.Name      = "Jacky";
            r.CreatedBy = "Admin";
            r.UpdatedBy = "Admin";

            DbEntry.Save(r);

            Role r1 = DbEntry.GetObject <Role>(r.Id);

            Assert.IsNotNull(r1);
            Assert.AreEqual("Admin", r1.CreatedBy);
            r1.Name = "Modified by jacky.";
            DbEntry.Update(r1);

            Role r2 = DbEntry.GetObject <Role>(r.Id);

            Assert.AreEqual("Modified by jacky.", r2.Name);
        }
Beispiel #5
0
        public void TestSavedOnForUpdate()
        {
            var o = new DateTable3 {
                Name = "tom", Id = 1
            };

            DbEntry.Update(o);
            Assert.AreEqual("UPDATE [DateTable] SET [SavedOn]=DATETIME(CURRENT_TIMESTAMP, 'localtime'),[Name]=@Name_0  WHERE [Id] = @Id_1;\n<Text><30>(@Name_0=tom:String,@Id_1=1:Int64)", StaticRecorder.LastMessage);
        }
Beispiel #6
0
        public void TestMkeyForUpdate()
        {
            var p = new Mkey2 {
                FirstName = "test", LastName = "next", Age = 11
            };

            DbEntry.Update(p);
            AssertSql(@"UPDATE [Mkey2] SET [Age]=@Age_0  WHERE ([FirstName] = @FirstName_1) AND ([LastName] = @LastName_2);
<Text><30>(@Age_0=11:Int32,@FirstName_1=test:String,@LastName_2=next:String)");
        }
Beispiel #7
0
        public void TestForMkey()
        {
            DbEntry.Create(typeof(Mkey));

            var p1 = new Mkey {
                FirstName = "test", LastName = "next", Age = 11
            };

            DbEntry.Insert(p1);

            var p2 = DbEntry.From <Mkey>().Where(p => p.FirstName == "test" && p.LastName == "next").Select()[0];

            Assert.AreEqual(11, p2.Age);

            p2.Age = 18;
            DbEntry.Update(p2);

            var p3 = DbEntry.From <Mkey>().Where(p => p.FirstName == "test" && p.LastName == "next").Select()[0];

            Assert.AreEqual(18, p3.Age);
        }