'Contains()' workaround using Linq to Entities?

前端 未结 10 2127
清酒与你
清酒与你 2020-11-22 14:01

I\'m trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does any

10条回答
  •  佛祖请我去吃肉
    2020-11-22 14:35

    You can fall back on hand coding some e-sql (note the keyword "it"):

    return CurrentDataSource.Product.Where("it.ID IN {4,5,6}"); 
    

    Here is the code that I used to generate some e-sql from a collection, YMMV:

    string[] ids = orders.Select(x=>x.ProductID.ToString()).ToArray();
    return CurrentDataSource.Products.Where("it.ID IN {" + string.Join(",", ids) + "}");
    

提交回复
热议问题