what is the difference between using exists
over contains
var s = new int[] { 1, 2, 3, 4, 5 };
dbset.where(x => s.contains(x.id);
or
var s = new int[] { 1, 2, 3, 4, 5 };
dbset.Where(x => s.Exists(y => x.id));
what is the difference between using exists
over contains
var s = new int[] { 1, 2, 3, 4, 5 };
dbset.where(x => s.contains(x.id);
or
var s = new int[] { 1, 2, 3, 4, 5 };
dbset.Where(x => s.Exists(y => x.id));
List<T>
, there is no such method on array or IEnumerable<T>
extensions.x => s.Exists(y => y == x.id)
(you should pass predicate, i.e. method which returns boolean)Contains
supported by Linq to Entities, Exists
is not supported.