You can’t use Contains
with non-primitive values. Do
Where(l => l.Courses.Select(c => c.CourseId).Contains(courseId)
(or the Id field you use).
More Related Contents:
- Dynamic where clause (OR) in Linq to Entities
- How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?
- “A lambda expression with a statement body cannot be converted to an expression tree”
- Why is .Contains slow? Most efficient way to get multiple entities by primary key?
- Bulk-deleting in LINQ to Entities
- Entity framework left join
- Why doesn’t Include have any effect?
- Entity Framework/Linq EXpression converting from string to int
- Value cannot be null. Parameter name: source
- Recursive Hierarchy – Recursive Query using Linq
- Filter/Search using Multiple Fields – ASP.NET MVC
- LINQ to Entities does not recognize the method ‘Int32 Int32(System.String)’ method, and this method cannot be translated into a store expression
- The result of a query cannot be enumerated more than once
- Entity Framework. Delete all rows in table
- How to convert an expression tree to a partial SQL query?
- “The LINQ expression node type ‘Invoke’ is not supported in LINQ to Entities” – stumped!
- Entity-framework code is slow when using Include() many times
- The operation cannot be completed because the DbContext has been disposed using MVC 4
- How does LINQ expression syntax work with Include() for eager loading
- Export Model to DataTable
- Dynamic query with OR conditions in Entity Framework
- Simulating Cross Context Joins–LINQ/C#
- Only primitive types or enumeration types are supported in this context
- Calling a SQL User-defined function in a LINQ query
- Max return value if empty query
- Check if list contains item from other list in EntityFramework
- How to do an “in” query in entity framework?
- Keep Getting ‘The LINQ expression node type ‘Invoke’ is not supported in LINQ to Entities’ Exception
- Should the order of LINQ query clauses affect Entity Framework performance?
- How to wrap Entity Framework to intercept the LINQ expression just before execution?