I want to query items with specific IDs using. For example:
var ids = new List<int> { 1, 3, 5 };
var items = context.Items.Where(item => ids.Contains(item.ID)).ToList();
Questions:
- Will this generate a single query with SQL
IN
operator?
- Is this code OK in terms of performance?
- Are there any better ways to do it?
I am using Entity Framework 6 with Microsoft SQL Server.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…