简体   繁体   中英

Are there DbContext functions not available in ObjectContext?

Microsoft has an introduction article describing DbContext features.

Some of them, like filtering related entities I hadn't seen in ObjectContext.

Is that functionality really new for DbContext and not available in ObjectContext? What are the other "new" functions? Or is DbContext just a simplified API over the same functionality that ObjectContext has?

From MSDN: DbContext wraps ObjectContext and exposes the most commonly used features of ObjectContext by using simplified and more intuitive APIs. You can access the underlying ObjectContext whenever you need to use features that are not supported by DbContext.

Loading the related entities is supported, but filtering them is not supported

ObjectContext.LoadProperty

So the answer is no for loading only a part of related entities (in my opinion), DbContext offers some helper methods. You can achieve the same with ObjectContext when turning off lazy-loading and (just query for the related entities).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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