开发者

Filter list as a parameter in a compiled query

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜