Question

I have the following compiled query that I want to return a list of "groups" that don't have a "GroupID" that's contained in a filtered list:

CompiledQuery.Compile(ConfigEntities contexty, List<int> list) =>
    from c in context.Groups
    where (!csList.Contains(c.GroupID))
    select c).ToList()

However I'm getting the following run-time error:

The specified parameter 'categories' of type 'System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c261364e126]]' is not valid. Only scalar parameters (such as Int32, Decimal, and Guid) are supported.

Any ideas?

Was it helpful?

Solution

This query will work fine in EF 4.

In EF 1, IEnumerable.Contains isn't supported in L2E (with or without CompiledQuery). There is a workaround, though; Google "BuildContainsExpression`, or look here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top