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.
Source: stackoverflow.com
Related Articles
- Query a many to many relationship with Entity Framework and .NET 3.5
- Proper Linq Query for objects with many to many relation ship generated with code first entity framework
- How to query many-to-many relationship with 'AND' condition using LINQ and Entity Framework
- Linq query with many to many relations using entity framework
- how to write a Linq query with a EF code first Many to Many relationship
- Entity Framework - How to improve query with many-to-many relationship
- How to run linq query on many-to-many relationship in c# with entity framework
- Dynamic query with OR conditions in Entity Framework
- Entity Framework Core: many-to-many relationship with same entity
- Entity Framework - Linq query with order by and group by
- Using a enum with flag in an Entity Framework query
- Entity Framework - An item with the same key has already been added. - Error when trying to define foreign key relationship
- Deleting multiple records with Entity Framework using a single LINQ query
- Always encrypted with Entity Framework and Includes fails to materialise query
- How can i write SQL update query with where clause in Entity Framework in C#
- Entity Framework with Oracle using odp.net not taking parameters in linq query
- Entity Framework Core LINQ query with multiple where clauses
- Optimize SQL generated by LINQ Query in Entity Framework 4.1 with one-to-many associations
- Wrong select query generated with Entity Framework (mysterious extra column)
- Entity Framework query to custom object Class with List
- Force inner join with many-to-many relationship entity framework
- Programmatically building a query with LINQ statement with entity framework
- Convert String to DateTime in LINQ query with Entity Framework Core
- Entity Framework Many to Many query
- many to many mapping in entity framework code first
- Dynamic query building with entity framework core - Build a query "by steps"
- Entity Framework 4.3 - Polymorphic Query With Eager Loading
- Entity Framework Core 2 One to Many created with Fluent API
- Exception raised when using a Linq query with Entity Framework
- updating data in many-to-many relationship in entity framework in code first existing database
- How to access the item after in a SortedSet
- Linq and IEnumerable lazy query. Efficiency lost?
- linq left join - select property of left entity
- linq to sql query cannot be translated error
- Query HTML file with LINQ
- How to return a 'Guid' from a 'Nullable<Guid>'?
- Dynamic Linq Where with Lambda Expression generates Error
- comparing dates with linq ambiguous
- How to create Expression filter for <T> List Comparison?
- How Is It Possible For a Group By To Return a Duplicate Key?
- C# Distinct in LINQ query
- Cast IEnumerable<PageData> to Episerver PageDataCollection
- Given two lists of objects, how do I compare into new KV in C#?
- Dynamic way to flatten arrays in classes?
- Select all data for duplicate objects
- How do I save a return list to table asp.net core
- How to include fields that are not the Key or aggregate in Linq Group by results?
- Linq Enumeration Error
- Return final result from stored procedure in Entity Framework
- Linq method for creating a sequence of separate objects?