开发者

Filter list as a parameter in a compiled query

开发者 https://www.devze.com 2022-12-31 03:59 出处:网络
I have the following compiled query that I want toreturn a list of \"groups\" that don\'t have a \"GroupID\" that\'s contained in a filtered list:

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

精彩评论

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