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 have two entities (Product and Category) with many to many associations.
How can I write queries over
All my attempts like:
result in exceptions like NotSupportedException (where is unsupported, select is unsupported, count is unsupported and so on). Can anyone offer working lightspeed query? |
|
|
Your best bet will be to use the underlying query syntax which will trigger an exists subquery to be appended to the criteria. Its a little simpler and clearer to understand what is being queried on. e.g.
or
Otherwise you can do this in LINQ by using .Any() as your filter, e.g.
or
|
|
|
Thanks, Jeremy! "Any" over associated collection is really translated by LightSpeed! My first case is solved. But your second example slightly differs from my second case. Your query returns products included in at least ONE given category. My need is to return products included in ALL categories. So I try the following (simply substitute "count" instead "any"):
Actually I started my experiments with this query. And it does not work - NotSupportedException "This overload of method 'Count' has no supported translation in LightSpeed". Of course I can dynamically build expression and get something like:
But it would be nice if I get static expression. Is there any way to do this? Thanks in advance, Jeremi! PS: I just found a thread describing similar constraint http://www.mindscapehq.com/forums/thread/4372. |
|