Entity Framework - attribute IN Clause usage

后端 未结 1 1950
面向向阳花
面向向阳花 2020-11-29 05:47

I need to filter some Entities by various fields using \"normal\" WHERE and IN clauses in a query over my database, but I do not know how to do that with EF.

This is

相关标签:
1条回答
  • 2020-11-29 06:28
    int[] ids = new int[]{1,2,3,45,99};
    using (DatabaseEntities db = new DatabaseEntities ())
    {
        return db.Licenses.Where(
            i => i.license == mylicense 
               && ids.Contains(i.number)
            ).ToList();
    }
    

    should work

    0 讨论(0)
提交回复
热议问题