I have two data sources, the first one uses OLEDB to connect and other uses SQL Data Provider.
I always create a DAL to encapsulate data access logic, but this time it seams I have to create two different DAL (OLDB and SQLProvider.
Will this is the right approach or I can communicate with single DAL. Please suggest what is the best approach followed while communicating different data source from ASp.NET application.
Thanks
You are right that you need to encapsulate the data access logic in a separate layer if you want to access two different data sources,
The key is to make sure that your other code, uses an interface, not an implementation, to access your DAL.
So for example:
In your code, you would program against the
IRepositoryinterface and you wouldn’t depend on a specific implementation. At runtime, you would select the rightRepositoryimplementation (for example with Dependency Injection).