Entity Framework CTP5 and Ninject as my IOC

Is it possible in Entity Framework CTP5 to build extracted objects with saving through an IOC container?

I use Ninject and it is perfectly connected with MVC, but I need to add some objects to the objects of my domain when they are built for some business rules.

I would rather do this using constructor injection than method or property injections.

+3
source share
3 answers

I'm not sure what exactly you are trying to do here, but EF has almost no breakdown points. The best you can do is hook into the ObjectMaterialized event fired by the ObjectContext. In CTP5, you need to drop your DbContext in the constructor for your DbContext:

((IObjectContextAdapter)this).ObjectContext.ObjectMaterialized += 
    this.ObjectContext_OnObjectMaterialized;

ObjectContext_OnObjectMaterialized(object sender, ObjectMaterializedEventArgs e). , , , . - .

, :

, -.

?

+1

, . , (, , ). - , , , . ( Ninject).

+1

, EF- CTP 5 . IValidatableObject, ValidationContext . ValidationContext - ServiceLocator, IoC validationContext. ( , ). , .

, , , , , . , , googling - . , , . , .

http://nripendra-newa.blogspot.com/2011/02/entity-framework-ctp5-injecting-with.html

, . , .

0

Source: https://habr.com/ru/post/1782765/


All Articles