Given the following example database structure:
Code: Select all
Tree 1 -> * Branch
Branch 1 -> * Leaf
Leaf 1 -> 0-1 LeafFallDetails
Code: Select all
dim result = context.Trees.Select(Function(t) New With {
.Tree = t,
.FallenLeaves = t.Branches.SelectMany(
Function(b) b.Leaves.Where(
Function(l) l.LeafFallDetails IsNot Nothing
)
)
}).ToList()
As a side note, sometimes I also seem to get a weird error when projecting to an anonymous type like in the above where I get an exception of something like:
Code: Select all
Unable to cast object of type 'CacheStorageReader[VB$AnonymousType_0`2[Data.Entities.Tree,System.Collections.Generic.IEnumerable`1[Data.Entities.Leaf]]]' to type 'Devart.Data.PostgreSql.PgSqlDataReader'.
Code: Select all
dim result = context.Trees.Select(Function(t) New With {
.Tree = t,
.Leaves = t.Branches.SelectMany(
Function(b) b.Leaves
)
}).ToList()
Many thanks for your help,
Peter