mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 ISelect.ToTreeList 扩展方法查询数据,加工为树型 List;(注意:实体需要配置父子导航属性)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests
|
||||
@ -318,6 +319,7 @@ namespace FreeSql.Tests
|
||||
cts[1].Goodss.Clear();
|
||||
cts[1].Goodss.Add(new Goods { Name = "<22><>Ʒ55" });
|
||||
repo.Update(cts);
|
||||
|
||||
}
|
||||
[Table(Name = "EAUNL_OTM_CT")]
|
||||
class Cagetory
|
||||
@ -390,6 +392,7 @@ namespace FreeSql.Tests
|
||||
[Fact]
|
||||
public void EnableAddOrUpdateNavigateList_OneToMany_Parent()
|
||||
{
|
||||
g.sqlite.Delete<CagetoryParent>().Where("1=1").ExecuteAffrows();
|
||||
var repo = g.sqlite.GetRepository<CagetoryParent>();
|
||||
var cts = new[] {
|
||||
new CagetoryParent
|
||||
@ -412,9 +415,12 @@ namespace FreeSql.Tests
|
||||
})
|
||||
}
|
||||
};
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = false; //<2F>رռ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>湦<EFBFBD><EFBFBD>
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //<2F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>湦<EFBFBD><EFBFBD>
|
||||
repo.Insert(cts);
|
||||
repo.SaveMany(cts[0], "Childs"); //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Childs һ<>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
var treelist1 = repo.Select.ToTreeList();
|
||||
|
||||
//repo.SaveMany(cts[0], "Childs"); //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Childs һ<>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
cts[0].Name = "<22><><EFBFBD><EFBFBD>11";
|
||||
cts[0].Childs.Clear();
|
||||
cts[1].Name = "<22><><EFBFBD><EFBFBD>22";
|
||||
@ -427,6 +433,7 @@ namespace FreeSql.Tests
|
||||
cts[1].Childs.Clear();
|
||||
cts[1].Childs.Add(new CagetoryParent { Name = "<22><><EFBFBD><EFBFBD>2_22" });
|
||||
repo.Update(cts);
|
||||
var treelist2 = repo.Select.ToTreeList();
|
||||
}
|
||||
[Table(Name = "EAUNL_OTMP_CT")]
|
||||
class CagetoryParent
|
||||
|
Reference in New Issue
Block a user