I got some static classes with extension methods that add “business logic” to objects using the repository template.
Now sometimes I need to create a new one IRepositoryin these extension functions.
I am currently working on this, accessing my Ninject core through an object that I am expanding, but it is really ugly:
public static IEnumerable<ISomething> GetSomethings(this IEntity entity)
{
using (var dataContext = entity.kernel.Get<IDataContext>())
return dataContext.Repository<ISomething>().ToList();
}
I could also create a static constructor by accessing the Ninject core in some way from the factory, is there already an infrastructure for this in Ninject 2?
Does anyone know a better solution? Does anyone have any comments on this for implementing business logic.