'Unable to compare elements of type' System.Collections.Generic.ICollection`1 '. Only primitive types (such as Int32, String, and Guid) and entity types are supported. ''
Entities and relationships (navigation properties):
Case (1 <-> ∞) MeetingCase (1 <-> ∞) MeetingCaseOutcomes
Violation Code:
IQueryable<Case> cases; // this is obviously attached to a context and able to access data) var broken = cases .Where(c => c.MeetingCases .Where(mc => mc.ExpectedStartDateTime <= DateTime.Now) .Any(m => m.MeetingCaseOutcomes == null || m.MeetingCaseOutcomes.Count == 0));
I assume that the problem is due to the lack of support for the "Any" operator, although I thought this would work in EF 4 (as support for the associated "Contains" operator was added).
How do I rebuild this call to create what I want?
I have been working with EF for several months now and understand many of the running hours.
UPDATE:
The Where clause contains the predicate above:
c.MeetingCases.Where(mc => mc.ExpectedStartDateTime <= DateTime.Now) .Any(m => m.MeetingCaseOutcomes == null || m.MeetingCaseOutcomes.Count == 0)
Because Any returns a boolean, the whole thing produces a predicate expression.
Furthermore, the purpose of this logic is to return a set of Case objects that do not have MeetingCaseOutcome entries for any MeetingCase entries where the meeting has already taken place (hence, a comparison with DateTime.Now). This is part of the meeting planning system, and this should verify that the results from each meeting are entered into the system after the meeting.
source share