Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 948
Shaddix Avatar asked Oct 11 '22 16:10

Shaddix


1 Answers

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

like image 189
yonexbat Avatar answered Oct 20 '22 14:10

yonexbat