使用ASP.NET Web API OData可以实现类似的功能吗:
List<string> customersTitles = Odata.OrdersService.Select(o=>o.CustomerTitle).Distinct().ToList();
List<Customer> customers = Odata.CustomerService.Where(m => customersTitles .Contains(m.CustomerTitle))
错误信息:
将Linq表达式翻译成URI时出错:表达式 value(System.Collections.Generic.List`1[System.String]).Contains([10007].CustomerTitle) 不受支持。
API:
public class CustomerController : EntitySetController<Customer, int>
{
[Queryable]
public override IQueryable<Customer> Get()
{
Expression filter = this.QueryOptions.Filter.ToExpression<Customer>();
return db.Query<Customer>(filter as Expression<Func<Customer, bool>>);
}
}