mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-12-20 00:25:48 +08:00
补充 IncludeMany 变异向下两级单元测试
This commit is contained in:
@@ -816,6 +816,15 @@ namespace FreeSql.Tests.Oracle {
|
||||
|
||||
public int model2111Idaaa { get; set; }
|
||||
public string title { get; set; }
|
||||
|
||||
public List<TiOtmModel4> childs2 { get; set; }
|
||||
}
|
||||
public class TiOtmModel4 {
|
||||
[Column(IsIdentity = true)]
|
||||
public int id { get; set; }
|
||||
|
||||
public int model3333Id333 { get; set; }
|
||||
public string title444 { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -825,17 +834,32 @@ namespace FreeSql.Tests.Oracle {
|
||||
var model2 = new TiOtmModel2 { model2id = model1.id, m2setting = DateTime.Now.Second.ToString() };
|
||||
g.oracle.Insert(model2).ExecuteAffrows();
|
||||
|
||||
var model3s = new[] {
|
||||
new TiOtmModel3{ model2111Idaaa = model1.id, title = "testmodel3__111" },
|
||||
new TiOtmModel3{ model2111Idaaa = model1.id, title = "testmodel3__222" },
|
||||
new TiOtmModel3{ model2111Idaaa = model1.id, title = "testmodel3__333" }
|
||||
var model3_1 = new TiOtmModel3 { model2111Idaaa = model1.id, title = "testmodel3__111" };
|
||||
model3_1.id = (int)g.oracle.Insert(model3_1).ExecuteIdentity();
|
||||
var model3_2 = new TiOtmModel3 { model2111Idaaa = model1.id, title = "testmodel3__222" };
|
||||
model3_2.id = (int)g.oracle.Insert(model3_2).ExecuteIdentity();
|
||||
var model3_3 = new TiOtmModel3 { model2111Idaaa = model1.id, title = "testmodel3__333" };
|
||||
model3_3.id = (int)g.oracle.Insert(model3_2).ExecuteIdentity();
|
||||
|
||||
var model4s = new[] {
|
||||
new TiOtmModel4{ model3333Id333 = model3_1.id, title444 = "testmodel3_4__111" },
|
||||
new TiOtmModel4{ model3333Id333 = model3_1.id, title444 = "testmodel3_4__222" },
|
||||
new TiOtmModel4{ model3333Id333 = model3_2.id, title444 = "testmodel3_4__111" },
|
||||
new TiOtmModel4{ model3333Id333 = model3_2.id, title444 = "testmodel3_4__222" },
|
||||
new TiOtmModel4{ model3333Id333 = model3_2.id, title444 = "testmodel3_4__333" }
|
||||
};
|
||||
Assert.Equal(3, g.oracle.Insert(model3s).ExecuteAffrows());
|
||||
Assert.Equal(5, g.oracle.Insert(model4s).ExecuteAffrows());
|
||||
|
||||
var t1 = g.oracle.Select<TiOtmModel1>()
|
||||
.IncludeMany(a => a.model2.childs.Where(m3 => m3.model2111Idaaa == a.model2.model2id))
|
||||
.Where(a => a.id <= model1.id)
|
||||
.ToList();
|
||||
|
||||
var t2 = g.oracle.Select<TiOtmModel1>()
|
||||
.IncludeMany(a => a.model2.childs.Where(m3 => m3.model2111Idaaa == a.model2.model2id),
|
||||
then => then.IncludeMany(m3 => m3.childs2.Where(m4 => m4.model3333Id333 == m3.id)))
|
||||
.Where(a => a.id <= model1.id)
|
||||
.ToList();
|
||||
}
|
||||
[Fact]
|
||||
public void Include_OneToChilds() {
|
||||
|
||||
Reference in New Issue
Block a user