This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I think it would be quite useful if EntityCollections implimented IQueryable. I find often I have an entity and I need to know info about its related data but only need a count or sum. I could code up the query by hand but it is so easy and nice to write myentity.Parts.Any(); |
|
|
+1 When you're adding better LINQ support in v3, having all the relationship collections of an entity implement IQueryable will help avoid loading the entire collection and queries being executed in memory. The relationship collection implementing IQueryable means you don't have to keep going back to the IQueryables on the unit of work and then filtering with the current entity identifier like you do at the moment. Using the relationship collections will be much nicer to read and write. It would really be great if you could preserve the default order of the child collection too (unless overriden by an OrderBy in the LINQ query of course) :) ~ J |
|
|
We've looked at this and for various reasons we don't really want to do it. (Basically there's a conflict between the deferred, on-demand semantics of IQueryable and the in-memory semantics of adding, removal and collection change notification (required for data binding). It's not an unresolvable conflict, but it's a fair bit of effort and likely to lead to confusing behaviour, especially when combined with eager load, the backward-compatibility requirement for indexed access, and the nondeterminism of re-performing the query every time the collection is accessed.) What we've implemented as a compromise is a new Query overload, which operates on an entity and takes a collection expression: Customer bob; public static class CustomerExtensions { // call this as follows: We don't automatically create extension methods for you because we think they might be confusing, but if you want something like this you can customise the LightSpeed templates. This feature is available in current nightly builds (you don't need to wait for 3.0). Feedback welcome. |
|
|
Thanks. I will try it out. |
|