支持 great-grandchildren (Insight.Database)

Support for great-grandchildren (Insight.Database)

使用 Insight.Database,我可以用 children 及其 grandchildren:

查询 object

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));

我有一组表 Parent -> Child -> 孙子 -> Great-Grandchild

我尝试使用 RecordId、ParentId、ChildRecords 属性都无济于事。另外,我所有的 类 都装饰有 [BindChildren(BindChildrenFor.All)].

有什么方法可以填充 Great-Grandchildren 吗?谢谢!

模式类似于孙子。对于 parents: 选择器,你只需要使用一个 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));

);