Custom Extension-Function to implement "IN" in c# (LINQ-2-Entities)

Viewed 1106

For example:

.Contains(...) is supporten in Linq2Entities and is transformed to "IN" SQL-Expression.

I wan to rewrite this query:

var foundExntities = myDbContext.MyEntityes.Where(o => new List<int> {111, 222, 333).Contains(o.ID)).ToList()

in form like there:

var foundExntities = myDbContext.MyEntityes.Where(o => o.ID.In(111, 222, 33)).ToList()

How can I write correspondend custom In(...) Extension-Function?

1 Answers
Related