我如何在实体框架中使用包含在内的条件 [英] How Can I Use Where Condition Inside Include In Entity Framework

查看:64
本文介绍了我如何在实体框架中使用包含在内的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我正在尝试使用实体框架查询中包含条件的地方,如下所示。



Hi All,


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

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





当我执行时我收到以下错误:



类型'的例外情况System.Argu mentException'发生在EntityFramework.dll中但未在用户代码中处理



附加信息:Include路径表达式必须引用在类型上定义的导航属性。使用虚线路径作为参考导航属性,使用Select运算符作为集合导航属性。





任何人都可以帮我解决这个问题。



谢谢,

Anil



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

推荐答案

目前不支持。



添加此请求 [ ^ ]在CodePlex网站上,但它可以追溯到2013年。讨论建议一些可能的解决方法。
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.


这篇关于我如何在实体框架中使用包含在内的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆