I know there are a lot of Repository Pattern questions out there but I hope someone will be kind enough to help me understand some principles.
I always see the repository class constructor using a context and this context is often EF or NHibernate. Its then easy to use the dbset<T>
for CRUD methods. Since I do not use anything like this, but rather make calls to a non-sql data source through API calls, I can't figure out how to use a Repository<T>
and a method like T GetById(int id)
when there is no underlying context that knows how to translate <T>
to the right obect. Do I have to create a custom context and my own data mapping? Will I end up having a specific Repository for every class I have? Somehow, somewhere, I need to take that <T>
and know what it is in order create it and fill in its properties.
I've seen some examples where the Repository Pattern is used with a File and it looks like each type has it own repository where the call and the mapping is done.
Any examples of Repository Pattern that targets multiple data sources?