Settings and activity
6 results found
-
2 votes
An error occurred while saving the comment Hugo supported this idea · -
248 votesHugo supported this idea ·
-
110 votesHugo supported this idea ·
-
303 votesHugo supported this idea ·
-
17 votesHugo supported this idea ·
-
49 votes
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.