I have an ObjectContext and a Repository that gets passed the ObjectContext. I then use the repository to make calls. I want to use dependency injection to not always have to instantiate the ObjectContext and Repository. What "object" would I group the context / repository into?
using (MOSContext db = new MOSContext())
{
IUserRepository users = new UserRepository(db);
// Do stuff with users.
}
Is this bad to do the above? Ideally, I'd like to be able to create "some object" that acts like the ObjectContext, but has accessors to all repository interfaces:
using (IDAL dal = IoC.Resolve<IDal>())
{
dal.Users.GetById(myId);
dal.Profiles.Add(new Profile());
}
Then using DI, I can register the context and all implementations for each repository interface.