diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom20.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom20.cs index 7a25c2d0d..993c846d0 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom20.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom20.cs @@ -11,14 +11,41 @@ namespace OrmTest public static void Init() { var db = NewUnitTest.Db; - var list = db.Queryable() + db.DbMaintenance.TruncateTable(); + db.Insertable(new Order() { Id = 1, Name = "jack", CreateTime = DateTime.Now, CustomId = 1 }).ExecuteCommand(); + var test1= db.Queryable() + .ToList(z => new { + name1 = new { z.Id, z.Name , ZId=100 } + }).First(); + + if (test1.name1.Id != 1 || test1.name1.Name != "jack" || test1.name1.ZId != 100) + { + throw new Exception("unit error"); + } + + var test2 = db.Queryable() + .ToList(z => new { + name1 = new { z.Id, z.Name, ZId = z.Id.ToString() } + }).First(); + + if (test2.name1.Id != 1 || test2.name1.Name != "jack" || test2.name1.ZId != "1") + { + throw new Exception("unit error"); + } + + var test3 = db.Queryable() .Take(2) .Select(i => new TestDTO { - SubOne = new TestSubDTO { NameOne = i.Name, NameTwo = i.Name }, - SubTwo = new TestSubDTO { NameOne = i.Name, NameTwo = i.Name } + SubOne = new TestSubDTO { NameOne = "a1", NameTwo = i.Id.ToString() }, + // SubTwo = new TestSubDTO { NameOne = i.Name, NameTwo = i.Name } }) - .ToList(); + .First(); + + if (test3.SubOne.NameOne !="a1"|| test3.SubOne.NameTwo != "1") + { + throw new Exception("unit error"); + } } public class TestDTO