如何在 Ado.Net WCF数据服务中编写'In'查询?我试过以下代码。
IList<int> orderIds = new List<int> { 59810, 59811, 59812, 59813, 59814 };
var lstorders = _context.Orders
.Where(o => orderIds.Contains(o.customerId))
.ToList<Orders>();
但上面的代码不起作用。我收到了以下错误。
测试'MyTest'失败:System.NotSupportedException:The 表达式(([10007] .customerId!= null)而且 值(System.Collections.Generic.List
1[System.Int32]).Contains([10007].customerId.Value)) is not supported. at System.Data.Services.Client.ExpressionWriter.ExpressionToString(DataServiceContext context, Expression e) at System.Data.Services.Client.UriWriter.VisitQueryOptionExpression(FilterQueryOptionExpression fqoe) at System.Data.Services.Client.UriWriter.VisitQueryOptions(ResourceExpression re) at System.Data.Services.Client.UriWriter.VisitResourceSetExpression(ResourceSetExpression rse) at System.Data.Services.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp) at System.Data.Services.Client.UriWriter.Translate(DataServiceContext context, Boolean addTrailingParens, Expression e, Uri& uri, Version& version) at System.Data.Services.Client.DataServiceQueryProvider.Translate(Expression e) at System.Data.Services.Client.DataServiceQuery
1.Execute() 在System.Data.Services.Client.DataServiceQuery1.GetEnumerator() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 源)