实体框架自动负载跃跃欲试 [英] Entity framework auto eager load
问题描述
有没有办法让实体对象通过关系,而不必不必.INCLUDE我想要的一切人口稠密自动将所有相关的数据?因为这需要序列化走了过来WCF我不能使用延迟加载。这纯粹是梦幻般的把它自动填充相关的收藏品。
Is there a way to get entity objects to automatically pull all relevant data through the relationships instead of having having to .Include everything I want populated? I can't use lazy loading as this needs to be serialized to go over WCF. It would just be fantastic to have it auto populate the relevant collections.
推荐答案
没有没有建立功能,它会自动eagear加载整个对象图。你必须始终明确地说,你要贪婪加载哪些导航性能(通过使用包含
方法或 LoadProperty
法)。
No there is no build in feature which will automatically eagear load whole object graph. You must always explicitly say which navigation properties you want to eager load (by using Include
method or LoadProperty
method).
编辑:
根据您的评论:一般来说应该有可能建立一些汽车装载机 - 但它并不容易。 的ObjectContext
具有包含有关实体的所有元数据 MetadataWorkspace
属性。您可以载入你的实体从元数据的所有信息,并添加所需的inclueds到查询。我想到一个问题 - 你必须以某种方式处理循环引用。如果你需要一些例子,如何提取有关实体的信息查询T4 POCO生成模板。
Based on your comment: Generally it should be possible to build some auto loader - but it will not be easy. ObjectContext
has MetadataWorkspace
property which contains all metadata about your entities. You can load all information about your entities from metadata and add needed inclueds to the query. I expect one problem - you must somehow handle cyclic references. If you need some example how to extract information about entities check T4 POCO generation template.
这篇关于实体框架自动负载跃跃欲试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!