'Contains()' workaround using Linq to Entities?

前端 未结 10 2137
清酒与你
清酒与你 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:39

    Thanks very much. WhereIn extension method was enough for me. I profiled it and generated the same SQL command to the DataBase as e-sql.

    public Estado[] GetSomeOtherMore(int[] values)
    {
        var result = _context.Estados.WhereIn(args => args.Id, values) ;
        return result.ToArray();
    }
    

    Generated this:

    SELECT 
    [Extent1].[intIdFRLEstado] AS [intIdFRLEstado], 
    [Extent1].[varDescripcion] AS [varDescripcion]
    FROM [dbo].[PVN_FRLEstados] AS [Extent1]
    WHERE (2 = [Extent1].[intIdFRLEstado]) OR (4 = [Extent1].[intIdFRLEstado]) OR (8 = [Extent1].[intIdFRLEstado])
    

提交回复
热议问题