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
|
Hi I'm trying to select entities based on some child entity criteria but I get Query Error: Could not find field [Count] on model [Product] var theCats = UnitOfWork.Categories
.Where(
c => c.Products So I want to select categories that have products that aren't "hidden", aren't "restricted" and have at least one image record. What's the right way to query this? Many thanks. |
|
|
You will need to use joins to handle this, e.g.
|
|
|
Thanks Jeremy. The above gives me duplicate categories - can you tell me how to get distinct categories from this? |
|
|
Ah, sorted - I'm getting distinct categories with: from c in UnitOfWork.Categories.Distinct() join p in UnitOfWork.Products on c.Id equals p.CategoryId join i in UnitOfWork.Images on p.Id equals i.ProductId where !p.Hidden && !p.Restricted orderby c.Name select c; |
|