gpt4 book ai didi

entity-framework - 如何在 WCF 数据服务中编写 'In' 查询?

转载 作者:行者123 更新时间:2023-12-01 13:03:00 25 4
gpt4 key购买 nike

如何在 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>();

但是上面的代码是行不通的。我收到以下错误。

Test 'MyTest' failed: System.NotSupportedException : The expression (([10007].customerId != null) And value(System.Collections.Generic.List1[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() at System.Data.Services.Client.DataServiceQuery1.GetEnumerator()
at System.Collections.Generic.List
1..ctor(IEnumerable1
collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)

最佳答案

关于entity-framework - 如何在 WCF 数据服务中编写 'In' 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4886545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com