Why is the ObjectContext class not derived from any interface?

I find people on MS smarter than me. I tried to create / test a repository that almost follows this , except that I want to freely link the ObjectContext dependency inside the repository. I learned that in order to separate this, I need to jump a lot of hoops, as shown in this article. Even such an approach is difficult to work when

  • Do you have edmx from an existing database
  • You have a common repository built around the ObjectContext interface and IObjectSet
  • During unit testing, you want to fake this object context and store all operations in memory. Think about testing repositories.

Now the real question is, why did the creators of ObjectContext decide not to have an IObjectContext?

I hope my question makes sense, I will be glad if someone can prove that he is not showing and showing me the way.

Thanks in advance!

+5
source share
1 answer

Since the context is a partial class, you can easily add the interface to it in a separate file: public partial class YourContext : IMyCustomInterfaceand you can put any signatures that you want to use from the generated ObjectContext into IMyCustomInterface.

( ) , , ObjectContext, , ( ) .

+5

All Articles