Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,


I am trying to use where condition inside include in an entity framework query as below.

SQL
var results = _courseService.QueryCourses()
                .Include(x => x.Language)
                .Include(x => x.Versions.Where(u=>u.Overwrite==null).Select(y => y.Language))
                .Include(x => x.Categories.Select(y => y.Category))
                .Include(x => x.CourseProvider)
                .Where(x => !x.IsDeleted && x.CourseProvider.Organisation.OrganisationID == CurrentUser.ActingAs.Value);


and when i am executing i am getting the below error:

An exception of type 'System.ArgumentException' occurred in EntityFramework.dll but was not handled in user code

Additional information: The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.


can any one help me how to fix this.

Thanks,
Anil
Posted
Comments
Richard Deeming 4-Mar-15 8:47am    
(Moved to answer.)
Maciej Los 4-Mar-15 8:50am    
Sounds like an answer ;)

1 solution

That's not currently supported.

There's a request to add this[^] over on the CodePlex site, but it dates back to 2013. The discussion suggests a few possible workarounds.
 
Share this answer
 
Comments
Maciej Los 4-Mar-15 9:05am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900