c# entity frame core で IN句 と NOT IN句

● c# entity frame core で IN句

SELECT * FROM myTable WHERE ID IN (1,2,3,4,5)
int[] ids = { 1, 2, 3, 4, 5};

var query = db.myTable.Where(item => ids.Contains(item.ID));

● c# entity frame core で NOT IN句

var badGuyIds = badGuys.Select(x => x.PersonId).ToArray();

context.Persons
    .Where(p => !badGuyIds.Contain(p.PersonId))
    .ToList();
No.1967
03/18 13:08

edit