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
|
using (var unitOfWork = Repository.Context.CreateUnitOfWork())
{
var results = unitOfWork
.ClassStateTransitions
.Where(cst => cst.FromMetaState.ClassStates.Any(cs => cs.QChannelClassId == 301949));
Assert.IsNotNull(results);
}
but am getting the following exception: base {System.Exception} = {"Query Error: Could not find field [QChannelClassId] on model [ClassStateTransition]"}
I'm guessing this is the nested Any() Linq Extension method that is causing me the trouble is this supported in Lightspeed?
|
|
|
Ok my mistake 2 seconds after posting this thread i realised i hadn't referenced the mindscape.linq assembly.
Cheers,
Stuart
|
|
|
I think that usage of Any inside a Where clause will turn out not to be supported even once you do add the reference. Currently we support Any (and similar aggregate operators like All and Sum) only over the result of a query. (Improving this is on our radar.) |
|
|
No your right..it doesn't work.
|
|
|
Hi Ivan,
Do you have any suggestion how i could perform this kind of query using LightSpeed?
Cheers.
|
|
|
To do it in LINQ, you need to flip the query around: var query = unitOfWork.ClassStates.Where(cs => cs.QChannelClassId == 301949).SelectMany(cs => cs.MetaState.ClassStateTransitions); (I'm guessing at the names of the reverse associations here.) You can also do it in the core API and it reads a bit more naturally: var results = unitOfWork.Find<ClassStateTransition>(Entity.Attribute("FromMetaState.ClassStates.QChannelClassId") == 301949); |
|
|
Thanks your a legend...I haven't got my linq head on today :)
|
|