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
|
LINQ to SQL supports this I was hoping I could get some light shed on this. If you try a query like... uow.Stories.Where(s => ids.Contains(s.Id)).ToList(); LightSPeed throws an exception... Unable to cast object of type 'System.Linq.Expressions.MemberExpression' to type 'System.Linq.Expressions.ConstantExpression'. I was going through all of my unit tests to make sure LightSpeed would work with my project until I hit this. Assuming there's a way to make this happen I willl probvably be purchasing LightSpeed, love it! |
|
|
For clarity ids is an IEnumerable<int> and Story.ID is an int. |
|
|
Hello Chad, Our LINQ implementation currently has a limitation that scalar operators like Contains or Sum can only be used over queries, not within Where clauses. Removing this limitation is a high priority for 3.0. I don't think we have a way of performing this query using LINQ syntax at the moment but one workaround is to use the core query API: uow.Find<Story>(Entity.Attribute("Id").In(ids.Cast<object>().ToArray())); Would this be a viable interim option for you? |
|
|
Hi Ivan,
It's a very useful reply and I used this as a hint to solve my problem with "Contains". There is one thing I want to point out though, the In predicate doesn't work with Guid[]. I tried to do List.ToArray() in the In method and got an can't map Guid[] to native type. which I believe the In method thinks Guid[] is a object instead of params object[]. I had to convert Guid[] to a string[] and it worked. So you might want to look at how the core API handles Guid. Hope this helps. Cheers, Nathan |
|
|
Ivan, has this been resolved yet? |
|
|
Yes.
|
|