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 like to write a query with the following expression: My model is as follow: A Person can have multiple Cards, a Card can have multiple CardStatus I want to get all Person where its latest CardStatus.CardStatusId is 1. I have something like below, but it's throwing an error saying that Card model does not have the field CardStatusId. How do I get around this? Thanks!! person => (person.Cards.Any( c => |
|
|
I think what you are looking for is: (from p in UnitOfWork.People (Your text says you want to check CardStatusId, but your sample code says CardStatusTypeId; I've assumed the latter.) I found that the Distinct() was needed because otherwise I got duplicate Person entities because of the join to Cards. But from testing I think we have a bug in this where it's returning any Person who has any Card with a CardStatus whose CardStatusTypeId of 1, not just where the *latest* CardStatus has a CardStatusTypeId is 1. So you may need to materialise these into a List and do the final filtering client-side. Let me know if you need me to log a bug for this (I can't promise when it might be addressed though). |
|