简体   繁体   English

是否在ObjectContext中没有DbContext函数?

[英]Are there DbContext functions not available in ObjectContext?

Microsoft has an introduction article describing DbContext features. Microsoft有一篇介绍DbContext功能的介绍文章

Some of them, like filtering related entities I hadn't seen in ObjectContext. 其中一些,比如我在ObjectContext中没有看到的过滤相关实体

Is that functionality really new for DbContext and not available in ObjectContext? 这个功能对于DbContext来说真的是新功能而在ObjectContext中不可用吗? What are the other "new" functions? 其他“新”功能是什么? Or is DbContext just a simplified API over the same functionality that ObjectContext has? 或者DbContext只是与ObjectContext具有相同功能的简化API?

From MSDN: DbContext wraps ObjectContext and exposes the most commonly used features of ObjectContext by using simplified and more intuitive APIs. 从MSDN:DbContext包装ObjectContext并使用简化和更直观的API公开ObjectContext最常用的功能。 You can access the underlying ObjectContext whenever you need to use features that are not supported by DbContext. 只要需要使用DbContext不支持的功能,就可以访问底层的ObjectContext。

Loading the related entities is supported, but filtering them is not supported 支持加载相关实体,但不支持过滤它们

ObjectContext.LoadProperty ObjectContext.LoadProperty

So the answer is no for loading only a part of related entities (in my opinion), DbContext offers some helper methods. 所以答案是不能只加载一部分相关实体(在我看来),DbContext提供了一些辅助方法。 You can achieve the same with ObjectContext when turning off lazy-loading and (just query for the related entities). 关闭延迟加载和(只查询相关实体)时,您可以使用ObjectContext实现相同的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM