score:1

Accepted answer

This will work in EFv4. Try it in EFv1:

var tagIds = new int[] { 6, 7 };
var query = context.Tags
                   .Where(t => tagIds.Contains(t.Id))
                   .SelectMany(t => t.Posts);

Edit:

I checked it and collection valued parameters + Contains were added in EFv4 so above example doesn't work in EFv1. This thread in MSDN forum provides workaround to allow IN operator in EFv1. Another recommended workaround is simply upgrade to EFv4 because there are many other improvements including significant improvement of performance.


Related Articles