public void TestCase_Base_Null() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(10); var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderBy(x => x.Id).ToList(); var listAc = context.Query <TeRelateA_B>().OrderBy(x => x.Id).ToList(); AssertExtend.StrictEqual(listEx, listAc); for (int i = 0; i < 10; i++) { Assert.NotNull(listAc[i].RelateB); } for (int i = 10; i < 20; i++) { Assert.Null(listAc[i].RelateB); } }
public void TestCase_Single_Relate2() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(20); var listC = InitialRelateTableC(20); var listD = InitialRelateTableD(20); var listE = InitialRelateTableE(20); var list = context.Query <TeRelateA_BX>().ToList(); Assert.Equal(listA.Count, list.Count); int i = 0; foreach (var item in list) { AssertExtend.Equal(listA[i], item); AssertExtend.Equal(listB[i], item.RelateB); AssertExtend.Equal(listC[i], item.RelateB.RelateC); AssertExtend.Equal(listD[i], item.RelateB.RelateD); AssertExtend.Equal(listE[i], item.RelateB.RelateE); AssertExtend.Equal(listE[i], item.RelateE); Assert.Equal(item, item.RelateE.RelateA); Assert.NotEqual(item.RelateE, item.RelateB.RelateE); Assert.Equal(item, item.RelateB.RelateC.RelateA); i++; } }
public void TestCase_Base_Single_Collection() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(18); var listCollection = InitialRelateTableCollection(15); { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).ToList(); var listAc = context.Query <TeRelateA_B_Collection>().ToList(); AssertExtend.Equal(listA, listAc); for (int i = 0; i < listAc.Count; i++) { var item = listAc[i]; AssertExtend.Equal(listEx[i], item); var collectionEx = listCollection.Where(x => x.RelateAId == item.Id).ToList(); var collectionAc = item.RelateCollection.ToList(); AssertExtend.StrictEqual(collectionEx, collectionAc); } } }
public void TestCase_Base_2Single() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(20); var listC = InitialRelateTableC(20); var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() join z in listC on x.Id equals z.RelateAId into pd from q in pd.DefaultIfEmpty() select new TeRelateA_BC { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p, RelateC = q }).ToList(); var listAc = context.Query <TeRelateA_BC>().ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public void TestCase_ObjectField_Query() { List <TeObjectField> list = CreateAndInsertObjectFieldTableList(45); List <TeObjectField> listEx = list; List <TeObjectField> listAc = context.Query <TeObjectField>().ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public void TestCase_ObjectField_Query_Where() { List <TeObjectField> list = CreateAndInsertObjectFieldTableList(45); TeObjectField item = list[2]; List <TeObjectField> listEx = list.Where(x => x.ObjectField == item.ObjectField).ToList(); List <TeObjectField> listAc = context.Query <TeObjectField>().Where(x => x.ObjectField == item.ObjectField).ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public void TestCase_ObjectField_Query_Null() { List <TeObjectField> list = CreateAndInsertObjectFieldTableList(45); List <TeObjectField> listEx = list.Where(x => x.ObjectFieldNull == null).ToList(); List <TeObjectField> listAc = context.Query <TeObjectField>().Where(x => x.ObjectFieldNull == null).ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public void TestCase_Query() { List <TeBaseFieldEntity> list = CreateAndInsertBaseFieldEntityTableList(45); List <TeBaseFieldEntity> listEx; List <TeBaseFieldEntity> listAc; listEx = list; listAc = context.Query <TeBaseFieldEntity>().ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public void TestCase_DefalutValue_Refresh() { context.TruncateTable <TeBaseFieldDefaultValue>(); var value = context.CreateNew <TeBaseFieldDefaultValue>(); context.Insert(value, true); var ac = context.SelectById <TeBaseFieldDefaultValue>(value.Id); AssertExtend.Equal(value, ac); }
public async Task TestCase_Query_Async() { List <TeBaseFieldEntity> list = CreateAndInsertBaseFieldEntityTableList(45); List <TeBaseFieldEntity> listEx; List <TeBaseFieldEntity> listAc; listEx = list; listAc = await context.Query <TeBaseFieldEntity>().ToListAsync(CancellationToken.None); AssertExtend.StrictEqual(listEx, listAc); }
public async Task TestCase_MiniValue_Refresh_Async() { await context.TruncateTableAsync <TeBaseFieldNullMiniValue>(CancellationToken.None); var value = context.CreateNew <TeBaseFieldNullMiniValue>(); await context.InsertAsync(value, true, CancellationToken.None); var ac = await context.SelectByIdAsync <TeBaseFieldNullMiniValue>(value.Id, CancellationToken.None); AssertExtend.Equal(value, ac); }
public void TestCase_Single() { List <TeBaseFieldEntity> list = CreateAndInsertBaseFieldEntityTableList(45); TeBaseFieldEntity ex; TeBaseFieldEntity ac; ex = list[0]; ac = context.Query <TeBaseFieldEntity>().First(); AssertExtend.StrictEqual(ex, ac); ex = list[10]; ac = context.Query <TeBaseFieldEntity>().ElementAt(10); AssertExtend.StrictEqual(ex, ac); }
public void TestCase_DefaultValue_BulkInsert_Refresh() { context.TruncateTable <TeBaseFieldDefaultValue>(); var list = new List <TeBaseFieldDefaultValue>(); for (int i = 0; i < 10; i++) { var value = context.CreateNew <TeBaseFieldDefaultValue>(); list.Add(value); } context.BatchInsert(list, true, true); var listAc = context.Query <TeBaseFieldDefaultValue>().ToList(); AssertExtend.Equal(list, listAc); }
public async Task TestCase_Single_Async() { List <TeBaseFieldEntity> list = CreateAndInsertBaseFieldEntityTableList(45); TeBaseFieldEntity ex; TeBaseFieldEntity ac; ex = list[0]; ac = await context.Query <TeBaseFieldEntity>().FirstAsync(CancellationToken.None); AssertExtend.StrictEqual(ex, ac); ex = list[10]; ac = await context.Query <TeBaseFieldEntity>().ElementAtAsync(10, CancellationToken.None); AssertExtend.StrictEqual(ex, ac); }
public async Task TestCase_MiniValue_BulkInsert_Refresh_Async() { await context.TruncateTableAsync <TeBaseFieldNullMiniValue>(CancellationToken.None); var list = new List <TeBaseFieldNullMiniValue>(); for (int i = 0; i < 10; i++) { var value = context.CreateNew <TeBaseFieldNullMiniValue>(); list.Add(value); } await context.BatchInsertAsync(list, true, true, CancellationToken.None); var listAc = await context.Query <TeBaseFieldNullMiniValue>().ToListAsync(CancellationToken.None); AssertExtend.Equal(list, listAc); }
public void TestCase_ObjectField_Join() { List <TeObjectField> list = CreateAndInsertObjectFieldTableList(45); var temlist = list.Where(x => x.Id <= 5).ToList(); list.AddRange(temlist); var sublist = temlist.Select(x => new { x.Id, x.ObjectField, x.ObjectFieldNull }).ToList(); context.BatchInsert(temlist); var listEx = list.GroupBy(x => x.ObjectField).Select(g => new { ObjectField = g.Key, Count = g.Count() }).ToList().OrderBy(x => x.ObjectField.DataInt).ToList() .Join(sublist, x => x.ObjectField, y => y.ObjectField, (x, y) => new { x.ObjectField, x.Count, y.Id, y.ObjectFieldNull }).ToList(); var ft = context.Query <TeObjectField>().Where(x => x.Id <= 5).Select(x => new { x.Id, x.ObjectField, x.ObjectFieldNull }); var listAc = context.Query <TeObjectField>().Aggregate(x => new { ObjectField = x.ObjectField, Count = Function.Count() }) .Join(ft, (x, y) => x.ObjectField == y.ObjectField) .Select((x, y) => new { x.ObjectField, x.Count, y.Id, y.ObjectFieldNull }) .ToList().OrderBy(x => x.ObjectField.DataInt).ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public void TestCase_Single_Relate1() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(20); var list = context.Query <TeRelateA_B_A>().ToList(); Assert.Equal(listA.Count, list.Count); int i = 0; foreach (var item in list) { AssertExtend.Equal(listA[i], item); AssertExtend.Equal(listB[i], item.RelateB); Assert.Equal(item, item.RelateB.RelateA); i++; } }
public void TestCase_CUD_Single_NoIdentity_Key() { context.TruncateTable <TeBaseFieldNoIdentityEntity>(); var item1 = context.CreateNew <TeBaseFieldNoIdentityEntity>(); item1.Id = 0; item1.Int32Field = 1; item1.DoubleField = 0.1; item1.VarcharField = "level1"; item1.DateTimeField = GetNow(); item1.EnumInt32Field = EnumInt32Type.Positive1; var retInsert = item1.Save(); Assert.Equal(0, item1.Id); Assert.Equal(1, retInsert); var item2 = context.SelectByKey <TeBaseFieldNoIdentityEntity>(item1.Id); AssertExtend.StrictEqual(item1, item2); item1.AllowUpdatePrimaryKey(); item1.Id = 1; item1.DateTimeField = GetNow(); item1.Int32Field = 2; item1.VarcharField = "level2"; item1.DoubleField = 0.2; item1.EnumInt32Field = EnumInt32Type.Negative1; var retUpdate = item1.Save(); Assert.Equal(0, item2.Id); Assert.Equal(1, retUpdate); var item3 = context.SelectByKey <TeBaseFieldNoIdentityEntity>(item1.Id); AssertExtend.StrictEqual(item1, item3); var itemn = context.SelectByKey <TeBaseFieldNoIdentityEntity>(0); Assert.Null(itemn); var retDelete = item1.Erase(); Assert.Equal(1, item3.Id); Assert.Equal(1, retDelete); var item4 = context.SelectByKey <TeBaseFieldNoIdentityEntity>(item1.Id); Assert.Null(item4); }
public void TestCase_CUD_Single_S2() { context.TruncateTable <TeBaseFieldEntity>(); var item = CreateAndInsertBaseFieldEntityTableList(1)[0]; var item1 = context.SelectById <MyBase2>(item.Id); item1.Id = 0; item1.Reset(); context.TruncateTable <MyBase2>(); var retInsert = item1.Save(); Assert.Equal(1, item1.Id); Assert.Equal(1, retInsert); var item2 = context.SelectById <MyBase2>(item1.Id); AssertExtend.StrictEqual(item1, item2); item1.DateTimeField = GetNow(); item1.DateTimeFieldNull = null; item1.Int32Field = 2; item1.Int32FieldNull = null; item1.DoubleField = 2.0d; item1.DoubleFieldNull = null; item1.VarcharField = "abc"; item1.VarcharFieldNull = null; item1.EnumInt32Field = EnumInt32Type.Zero; item1.EnumInt32FieldNull = null; item1.EnumInt64Field = EnumInt64Type.Zero; item1.EnumInt64FieldNull = null; var retUpdate = item1.Save(); Assert.Equal(1, item1.Id); Assert.Equal(1, retUpdate); var item3 = context.SelectById <MyBase2>(item1.Id); AssertExtend.StrictEqual(item1, item3); var retDelete = item1.Erase(); Assert.Equal(1, item1.Id); Assert.Equal(1, retDelete); var item4 = context.SelectById <MyBase2>(item1.Id); Assert.Null(item4); }
public void TestCase_ObjectField_Aggregate() { List <TeObjectField> list = CreateAndInsertObjectFieldTableList(45); var temlist = list.Take(5).ToList(); list.AddRange(temlist); context.BatchInsert(temlist); var listEx = list.GroupBy(x => x.ObjectField).Select(g => new { ObjectField = g.Key, Count = g.Count() }).ToList().OrderBy(x => x.ObjectField.DataInt).ToList(); var listAc = context.Query <TeObjectField>().Aggregate(x => new { ObjectField = x.ObjectField, Count = Function.Count() }).ToList().OrderBy(x => x.ObjectField.DataInt).ToList(); AssertExtend.StrictEqual(listEx, listAc); }
public async Task TestCase_CUD_Bulk_Async() { const int count = 33; var listEx = CreateBaseFieldEntityTableList(count); List <TeBaseFieldEntity> listAc; await context.TruncateTableAsync <TeBaseFieldEntity>(CancellationToken.None); var retInsert = await context.BatchInsertAsync(listEx, CancellationToken.None); Assert.Equal(count, retInsert); listAc = await context.Query <TeBaseFieldEntity>().ToListAsync(CancellationToken.None); AssertExtend.Equal(listEx, listAc); DateTime d = GetNow(); listEx.ForEach(x => { x.DateTimeField = d; x.DateTimeFieldNull = null; x.Int32Field = 2; x.Int32FieldNull = null; x.DoubleField = 2.0d; x.DoubleFieldNull = null; x.VarcharField = "abc"; x.VarcharFieldNull = null; x.EnumInt32Field = EnumInt32Type.Zero; x.EnumInt32FieldNull = null; x.EnumInt64Field = EnumInt64Type.Zero; x.EnumInt64FieldNull = null; }); var retUpdate = await context.BatchUpdateAsync(listEx, CancellationToken.None); Assert.Equal(count, retUpdate); listAc = await context.Query <TeBaseFieldEntity>().ToListAsync(CancellationToken.None); AssertExtend.Equal(listEx, listAc); var retDelete = await context.BatchDeleteAsync(listEx, CancellationToken.None); Assert.Equal(count, retDelete); listAc = await context.Query <TeBaseFieldEntity>().ToListAsync(CancellationToken.None); AssertExtend.Equal(0, listAc.Count); }
public void TestCase_Config_Relate_Extend() { var listA = CreateAndInsertMainTableListExtend(10); var listB = CreateAndInsertSubTableList(5); { var listEx = (from x in listA join y in listB on x.Id equals y.MainId into ps from p in ps.DefaultIfEmpty() select new TeRelateMainExtendConfig { Id = x.Id, DecimalField = x.DecimalField, DateTimeField = x.DateTimeField, VarcharField = x.VarcharField, SubConfig = p }).OrderByDescending(x => x.Id).ToList(); var listAc = context.Query <TeRelateMainExtendConfig>().OrderByDescending(x => x.Id).ToList(); AssertExtend.StrictEqual(listEx, listAc); } }
public void TestCase_Base_Collection() { var listA = InitialRelateTableA(20); var listCollection = InitialRelateTableCollection(15); { var listAc = context.Query <TeRelateA_LCollection>().ToList(); AssertExtend.Equal(listA, listAc); for (int i = 0; i < listAc.Count; i++) { var item = listAc[i]; var collectionEx = listCollection.Where(x => x.RelateAId == item.Id).ToList(); var collectionAc = item.RelateCollection.ToList(); AssertExtend.StrictEqual(collectionEx, collectionAc); } } { var listAc = context.Query <TeRelateA_ICollection>().ToList(); AssertExtend.Equal(listA, listAc); for (int i = 0; i < listAc.Count; i++) { var item = listAc[i]; var collectionEx = listCollection.Where(x => x.RelateAId == item.Id).ToList(); var collectionAc = item.RelateCollection.ToList(); AssertExtend.StrictEqual(collectionEx, collectionAc); } } { var listAc = context.Query <TeRelateA_2Collection>().ToList(); AssertExtend.Equal(listA, listAc); for (int i = 0; i < listAc.Count; i++) { var item = listAc[i]; var collectionEx = listCollection.Where(x => x.RelateAId == item.Id).ToList(); var collectionLAc = item.RelateLCollection.ToList(); AssertExtend.StrictEqual(collectionEx, collectionLAc); var collectionIAc = item.RelateICollection.ToList(); AssertExtend.StrictEqual(collectionEx, collectionIAc); } } }
public async Task TestCase_CUD_Single_Async() { await context.TruncateTableAsync <TeBaseFieldEntity>(CancellationToken.None); var item1 = CreateBaseFieldEntityTableList(1)[0]; var retInsert = await item1.SaveAsync(CancellationToken.None); Assert.Equal(1, item1.Id); Assert.Equal(1, retInsert); var item2 = await context.SelectByIdAsync <TeBaseFieldEntity>(item1.Id, CancellationToken.None); AssertExtend.StrictEqual(item1, item2); item1.DateTimeField = GetNow(); item1.DateTimeFieldNull = null; item1.Int32Field = 2; item1.Int32FieldNull = null; item1.DoubleField = 2.0d; item1.DoubleFieldNull = null; item1.VarcharField = "abc"; item1.VarcharFieldNull = null; item1.EnumInt32Field = EnumInt32Type.Zero; item1.EnumInt32FieldNull = null; item1.EnumInt64Field = EnumInt64Type.Zero; item1.EnumInt64FieldNull = null; var retUpdate = await item1.SaveAsync(CancellationToken.None); Assert.Equal(1, item1.Id); Assert.Equal(1, retUpdate); var item3 = await context.SelectByIdAsync <TeBaseFieldEntity>(item1.Id, CancellationToken.None); AssertExtend.StrictEqual(item1, item3); var retDelete = await item1.EraseAsync(CancellationToken.None); Assert.Equal(1, item1.Id); Assert.Equal(1, retDelete); var item4 = await context.SelectByIdAsync <TeBaseFieldEntity>(item1.Id, CancellationToken.None); Assert.Null(item4); }
public void TestCase_CUD_Bulk() { const int count = 33; var listEx = CreateBaseFieldEntityTableList(count); List <TeBaseFieldEntity> listAc; context.TruncateTable <TeBaseFieldEntity>(); var retInsert = context.BatchInsert(listEx); Assert.Equal(count, retInsert); listAc = context.Query <TeBaseFieldEntity>().ToList(); AssertExtend.Equal(listEx, listAc); DateTime d = GetNow(); listEx.ForEach(x => { x.DateTimeField = d; x.DateTimeFieldNull = null; x.Int32Field = 2; x.Int32FieldNull = null; x.DoubleField = 2.0d; x.DoubleFieldNull = null; x.VarcharField = "abc"; x.VarcharFieldNull = null; x.EnumInt32Field = EnumInt32Type.Zero; x.EnumInt32FieldNull = null; x.EnumInt64Field = EnumInt64Type.Zero; x.EnumInt64FieldNull = null; }); var retUpdate = context.BatchUpdate(listEx); Assert.Equal(count, retUpdate); listAc = context.Query <TeBaseFieldEntity>().ToList(); AssertExtend.Equal(listEx, listAc); var retDelete = context.BatchDelete(listEx); Assert.Equal(count, retDelete); listAc = context.Query <TeBaseFieldEntity>().ToList(); AssertExtend.Equal(0, listAc.Count); }
public async Task TestCase_CUD_Single_NoIdentity_Async() { await context.TruncateTableAsync <TeBaseFieldNoIdentityEntity>(CancellationToken.None); var item1 = context.CreateNew <TeBaseFieldNoIdentityEntity>(); item1.Id = 0; item1.Int32Field = 1; item1.DoubleField = 0.1; item1.VarcharField = "level1"; item1.DateTimeField = GetNow(); item1.EnumInt32Field = EnumInt32Type.Positive1; var retInsert = await item1.SaveAsync(CancellationToken.None); Assert.Equal(0, item1.Id); Assert.Equal(1, retInsert); var item2 = await context.SelectByKeyAsync <TeBaseFieldNoIdentityEntity>(item1.Id, CancellationToken.None); AssertExtend.StrictEqual(item1, item2); item1.DateTimeField = GetNow(); item1.Int32Field = 2; item1.VarcharField = "level2"; item1.DoubleField = 0.2; item1.EnumInt32Field = EnumInt32Type.Negative1; var retUpdate = await item1.SaveAsync(CancellationToken.None); Assert.Equal(0, item2.Id); Assert.Equal(1, retUpdate); var item3 = await context.SelectByKeyAsync <TeBaseFieldNoIdentityEntity>(item1.Id, CancellationToken.None); AssertExtend.StrictEqual(item1, item3); var retDelete = await item1.EraseAsync(CancellationToken.None); Assert.Equal(0, item3.Id); Assert.Equal(1, retDelete); var item4 = await context.SelectByKeyAsync <TeBaseFieldNoIdentityEntity>(item1.Id, CancellationToken.None); Assert.Null(item4); }
public void TestCase_InsertOrUpdate_Single() { context.TruncateTable <TeBaseFieldEntity>(); var item1 = CreateBaseFieldEntityTableList(1)[0]; var retInsert = context.InsertOrUpdate(item1); Assert.Equal(1, item1.Id); Assert.Equal(1, retInsert); var item2 = context.SelectById <TeBaseFieldEntity>(item1.Id); AssertExtend.StrictEqual(item1, item2); item1.DateTimeField = GetNow(); item1.DateTimeFieldNull = null; item1.Int32Field = 2; item1.Int32FieldNull = null; item1.DoubleField = 2.0d; item1.DoubleFieldNull = null; item1.VarcharField = "abc"; item1.VarcharFieldNull = null; item1.EnumInt32Field = EnumInt32Type.Zero; item1.EnumInt32FieldNull = null; item1.EnumInt64Field = EnumInt64Type.Zero; item1.EnumInt64FieldNull = null; var retUpdate = context.InsertOrUpdate(item1); Assert.Equal(1, item1.Id); Assert.Equal(1, retUpdate); var item3 = context.SelectById <TeBaseFieldEntity>(item1.Id); AssertExtend.StrictEqual(item1, item3); var retDelete = context.Delete(item1); Assert.Equal(1, retDelete); var item4 = context.SelectById <TeBaseFieldEntity>(item1.Id); Assert.Null(item4); }
public void TestCase_Base_Where() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(18); { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Where(x => x.Id <= 1010).ToList(); var listAc = context.Query <TeRelateA_B>().Where(x => x.Id <= 1010).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Where(x => x.RelateB != null && x.RelateB.Id <= 2010).ToList(); var listAc = context.Query <TeRelateA_B>().Where(x => x.RelateB.Id <= 2010).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Where(x => x.Id > 1005 && x.RelateB != null && x.RelateB.Id <= 2010).ToList(); var listAc = context.Query <TeRelateA_B>().Where(x => x.Id > 1005 && x.RelateB.Id <= 2010).ToList(); AssertExtend.StrictEqual(listEx, listAc); var listAc1 = context.Query <TeRelateA_B>().Where(x => x.Id > 1005).WhereWithAnd(x => x.RelateB.Id <= 2010).ToList(); AssertExtend.StrictEqual(listEx, listAc1); } }
public void TestCase_Base_PageSkipTake() { const int tol = 21; const int cnt = 8; var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(20); int times = tol / cnt; times++; for (int i = 0; i < times; i++) { { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Skip(cnt * i).ToList(); var listAc = context.Query <TeRelateA_B>().Skip(cnt * i).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Take(cnt * i).ToList(); var listAc = context.Query <TeRelateA_B>().Take(cnt * i).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Skip(cnt * i).Take(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().Skip(cnt * i).Take(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Where(x => x.Id > cnt).Take(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().Where(x => x.Id > cnt).Take(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderByDescending(x => x.Id).Take(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().OrderByDescending(x => x.Id).Take(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Where(x => x.Id > cnt).Skip(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().Where(x => x.Id > cnt).Where(x => x.Id > cnt).Skip(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderByDescending(x => x.Id).Skip(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().OrderByDescending(x => x.Id).Skip(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).Where(x => x.Id > cnt).Skip(cnt).Take(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().Where(x => x.Id > cnt).Where(x => x.Id > cnt).Skip(cnt).Take(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderByDescending(x => x.Id).Skip(cnt).Take(cnt).ToList(); var listAc = context.Query <TeRelateA_B>().OrderByDescending(x => x.Id).Skip(cnt).Take(cnt).ToList(); AssertExtend.StrictEqual(listEx, listAc); } }
public void TestCase_Base_Order() { var listA = InitialRelateTableA(20); var listB = InitialRelateTableB(20); { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderByDescending(x => x.Id).ToList(); var listAc = context.Query <TeRelateA_B>().OrderByDescending(x => x.Id).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderByDescending(x => x.RelateB.Id).ToList(); var listAc = context.Query <TeRelateA_B>().OrderByDescending(x => x.RelateB.Id).ToList(); AssertExtend.StrictEqual(listEx, listAc); } { var listEx = (from x in listA join y in listB on x.Id equals y.RelateAId into ps from p in ps.DefaultIfEmpty() select new TeRelateA_B { Id = x.Id, RelateBId = x.RelateBId, RelateCId = x.RelateCId, RelateDId = x.RelateDId, RelateEId = x.RelateEId, RelateFId = x.RelateFId, DecimalField = x.DecimalField, VarcharField = x.VarcharField, DateTimeField = x.DateTimeField, RelateB = p }).OrderByDescending(x => x.Id).ToList(); var listAc = context.Query <TeRelateA_B>().OrderBy(x => x.RelateB.DecimalField).OrderByDescending(x => x.Id).ToList(); AssertExtend.StrictEqual(listEx, listAc); } }