简体   繁体   中英

Generic Data Access Layer

I want to build a generic data access layer targeting any multiple databases ie SQL Server, Oracle, DB2, etc, and the tricky part is that I need to also support Web Services, so my datasource can also be a Web Service. Each of the data sources have similar data but the column names are different and the return type(s) are different in the web services as well.

How can i create a generic Data access layer to target any datasource and return a generic object/list to the UI in .NET, C#.

.NET 4.5, C#, Web API, VS 2013 is what i am using.

Please suggest. Any help is greatly appreciated.

cheers

You are making things way too complicated in my opinion. Just create data access components for every data source type you have, and have them return business or domain entities that you define. Use the power of each data source to its fullest instead of trying to make them 'generic'.

Also, why treat a web service as a data source? It's a web service, already abstracted out. Just use it in your application layer and use its entities.

Bottom line: if it's too hard to do, then don't do it and keep it simple.

Also read http://ayende.com/blog/4567/the-false-myth-of-encapsulating-data-access-in-the-dal .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM