2011-02-03 32 views
3

如何在 Ado.Net中寫入'In'查詢 WCF Data Services?我已經嘗試了下面的代碼。如何在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:該 表達式(([10007] .customerId = 空)和 值(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.DataServiceQuery 1.GetEnumerator() at System.Collections.Generic.List 1..ctor(IEnumerable的源)

+0

「ADO.NET數據服務」(f.k.a. 「Astoria)在一年前更名爲** WCF Data Services ** ... – 2011-02-03 13:26:20

回答

1

WCF數據服務 'WHERE IN', 'WHERE NOT IN' 延伸方法sample