Retrieve entities with children per one sql call. ADO.NET Entity framework
Posted
by Andrew Florko
on Stack Overflow
See other posts from Stack Overflow
or by Andrew Florko
Published on 2010-05-01T15:27:58Z
Indexed on
2010/05/01
15:37 UTC
Read the original article
Hit count: 263
Hello everybody,
I have two tables: A & B
B { B1: Field1, B2: Field2, ... }
A { Children: List of B, A1: Field1, A2: Field2, }
I want to retrieve "A" entities with related "B" entities like this:
DataContext.A.Select( a => new MySubset( A1 = a.A1, Children = a.Children.Select(b => b.B1).ToList());
But EF can't translate ToList into SQL, so i have to call ToList() per each instance in query producing additional network call.
How can I avoid this?
Thank you in advance.
© Stack Overflow or respective owner