Okay. I've started a new project using MVC3. I've implemented EF4.1,Automapper, Ninject, PagedList from NuGet.
I've spent two days fleshing out my patterns, setting up IOCs and interfaces. I am injecting my service into my controller, my repository into my service, and my DbContext into my Repository.
What I'm left with is an application that runs and all is good. The problem I'm having is that we are in the process of changing vendors for agency's main system. This means the Database structure will be significantly changing.
Would it be correct for me to create two concrete implementations of ICamaContext and two Concrete implementations of ICamaRepository? One for each Database? Then in each repository, I would map my corresponding dbsets to my types to match the contract defined in ICamaRepository?
I'm not sure if that makes any sense. So in other words, I don't want to rewrite anything in my service regardless of which DB backend is being used.
namespace search.Common.Repositories
{
public interface ICamaRepository
{
IQueryable<Parcel> GetParcels();
}
public class AssessProCamaRepository : ICamaRepository
{
ICamaContext _db;
public AssessProCamaRepository(ICamaContext dataContext)
{
_db = dataContext;
}
public IQueryable<Parcel> GetParcels()
{
return from c in _db.DataProperty
select new Parcel
{
AccountNumber = c.AccountNumber
};
}
}
}