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 have a query where I try to use the keyword "let" to filter my list but I receive an error while trying to execute it. Just for the information, the reason why I use this keyword is for filter like a IN SQL. Here is the query:
var questions = from p in Questions join s in ProgramStructures on p.Id equals s.ItemId let filteredCategories = (from c in Categories where c.VersionId == 1016771 select c.Id) where filteredCategories.Contains(p.CategoryId) orderby p.CategoryId, s.Position select p;
questions.Dump();
The error I receive is "NotSupportedException"; Not an entity type.
When I write the query in two statements, the query is execute successfully:
var filteredCategories = (from c in Categories where c.VersionId == 1016771 select c.Id);
var questions = from p in Questions join s in ProgramStructures on p.Id equals s.ItemId where filteredCategories.Contains(p.CategoryId) orderby p.CategoryId, s.Position select p;
questions.Dump();
Also, if I look at the LS Generated code, all is ok.
Is NotSupportedException is an exception of LightSpeed throw to tells that it is not possible to place from, where keywords in the let keyword statement or I missing something in my query?
|
|
|
Yes, We throw a NotSupportedException when we encounter something in the LINQ query which we dont believe can be translated. In this case however it looks like we will need to have a look at what is going on as the query should be able to be translated (and is translated when you write it a different way). For now stick with the seperate query approach and I will post an update if we are able to resolve the issue with expressing it via let.
Thanks! Jeremy |
|