If I have an entity EntityA, which is an Entity Framework object, how would I go about injecting different behavior at time of creation?
These particular entities need to utilize a different strategy for some calculations. I would like to use DI to supply the correct strategy when the object is created. Is there any way to intercept?
Added: i thinking on the two patterns below (just pseudo to get the point across).
public partial class Entity
{
public Entity(ICalculationStrategy strategy)
{
_calcStrategy = strategy;
}
}
public partial class Entity
{
public Entity(ICalculationFactory factory)
{
_calcStrategy = factory.ProvideCalculator(this);
}
}