[英]Insight.Database [BindChildren] on subclass not working
[英]Support for great-grandchildren (Insight.Database)
使用Insight.Database,我可以查詢帶有子代及其子代的對象:
var someObject = connection.Query("SomeStoredProc", new {ParentId = id}, Query.Returns(Some<Parent>.Records) .ThenChildren(Some<Child>.Records) .ThenChildren(Some<Grandchild>.Records, parents: parent=> parent.Children, into: (child, grandchildren) => child.Grandchildren = grandchildren));
我有一組桌子父母->子->孫子->曾孫
我嘗試使用RecordId,ParentId,ChildRecords屬性無濟於事。 另外,我所有的班級都用[BindChildren(BindChildrenFor.All)]裝飾。
有沒有辦法讓大孫子們聚居? 謝謝!
這種模式類似於孫輩。 對於父母:選擇器,您只需要使用SelectMany即可獲取孫輩的完整列表。
(至少這是應該起作用的方式...)
var someObject = connection.Query("SomeStoredProc", new {ParentId = id},
Query.Returns(Some<Parent>.Records)
.ThenChildren(Some<Child>.Records)
.ThenChildren(Some<Grandchild>.Records,
parents: parent=> parent.Children,
into: (child, grandchildren) => child.Grandchildren = grandchildren)
.ThenChildren(Some<GreatGrandchild>.Records,
parents: parent=> parent.Children.SelectMany(c => c.Grandchildren)),
into: (grandchild, greatgrantchildren) => grandchild.greatgrantchildren= greatgrantchildren));
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.