How to do a “where in values” in LINQ-to-Entities 3.5

前端 未结 7 1274
时光说笑
时光说笑 2020-12-15 18:42

Does anybody know how to apply a \"where in values\" type condition using LINQ-to-Entities? I\'ve tried the following but it doesn\'t work:

var values = new         


        
7条回答
  •  有刺的猬
    2020-12-15 19:26

    FYI:

    If you are using ESql you are able to use in operation. I don't have VS 2008 With me but code should be something like following:

    var ids = "12, 34, 35";
    using (context = new Entites())
    {
        var selectedProducts = context.CreateQuery(
            String.Format("select value p from [Entities].Products as p 
                           where p.productId in {{{0}}}", ids)).ToList();
        ...
    }
    

提交回复
热议问题