I would like to know how I can change this query:
events = _database.Events
.Include("Contacts")
.ToList();
To inclu开发者_Python百科de only contacts having their property "Type" set to "event".
I'm using EntityFramework, _database is its context.
Firstly, it's worth understanding that the code you posted doesn't include a lambda expression at all. "Query not in query expression syntax" isn't the same as "lambda expression".
I suspect it would be a bad idea to return event objects with a partially-filled entity reference set. However, you could do this:
_database.Events
.Select(e => new { Event = e,
EventContacts e.Contacts
.Where(c => c.Type == "event") });
精彩评论