- 完善 AsTreeCte + ToUpdate/ToDelete 实现树所有子节点删除或更新;

This commit is contained in:
28810
2020-08-04 20:54:15 +08:00
parent 255cbf33aa
commit 18cabd22b9
24 changed files with 346 additions and 63 deletions

View File

@ -1750,6 +1750,22 @@ WHERE (((cast(a.[Id] as nvarchar(100))) in (SELECT b.[Title]
Assert.Equal("中国[100000] -> 北京[110000]", t4[1].path);
Assert.Equal("中国[100000] -> 北京[110000] -> 北京市[110100]", t4[2].path);
Assert.Equal("中国[100000] -> 北京[110000] -> 东城区[110101]", t4[3].path);
var select = fsql.Select<VM_District_Child>()
.Where(a => a.Name == "中国")
.AsTreeCte()
//.OrderBy("a.cte_level desc") //递归层级
;
// var list = select.ToList(); //自己调试看查到的数据
select.ToUpdate().Set(a => a.testint, 855).ExecuteAffrows();
Assert.Equal(855, fsql.Select<VM_District_Child>()
.Where(a => a.Name == "中国")
.AsTreeCte().Distinct().First(a => a.testint));
Assert.Equal(4, select.ToDelete().ExecuteAffrows());
Assert.False(fsql.Select<VM_District_Child>()
.Where(a => a.Name == "中国")
.AsTreeCte().Any());
}
[Table(Name = "D_District")]
@ -1763,6 +1779,8 @@ WHERE (((cast(a.[Id] as nvarchar(100))) in (SELECT b.[Title]
[Column(StringLength = 6)]
public virtual string ParentCode { get; set; }
public int testint { get; set; }
}
[Table(Name = "D_District", DisableSyncStructure = true)]
public class VM_District_Child : BaseDistrict