Options to control nested lists auto expanding or
Options to control nested lists auto expanding enable or disable
very commonly need parent list expanded but nested objects and their lists unexpanded
-
Hugo commented
I was wanting to do this today, and "hacked" around it by manually querying the child entity table while creating an anonymous object. While it worked, it felt "dirty", not to mention, the SQL which executed wasn't all that great.
My thought was something like a fluent extension method, such as this:
Persons.Where(p => p.LastName = "Smythe" && (p.EmailAddresses.Count() > 2 || p.Addresses.Count() > 2)).
.Expand<Person>(p => p.EmailAddresses) // The generic type parameter is for example, can certianly be inferred from use
.Expand<Person>(p => p.Addresses, 5) // Same as above, but only do so if there are 5 or less child rows. Otherwise, display a link, as is done today.
.Dump();That would display the rows from the "Person" which match the condition, and auto-expand the "Addresses" and "EmailAddresses" child/linked entities. In the case of addresses, it would only auto-expand for "Person" rows where there are 5 or less "Address" child entities. Having a parameter for the number of parent ("Person") entities may not be a bad idea either.