LINQ, Unable to create a constant value of type XXX. Only primitive types or enumeration types are supported in this context

前端 未结 5 637
我寻月下人不归
我寻月下人不归 2020-11-30 01:58

In my application I have Lecturers and they have list of Courses they can teach and when I\'m deleting a course I want to remove connection to lecturers. Here\'s the code:

5条回答
  •  醉话见心
    2020-11-30 02:44

    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).

提交回复
热议问题