开发者

How can I wrap tables into a more generic class for use with multiple data contexts?

开发者 https://www.devze.com 2023-01-11 16:25 出处:网络
I have two different DataContexts (SQL Databases开发者_开发技巧) that have the same data, just with slightly different naming:

I have two different DataContexts (SQL Databases开发者_开发技巧) that have the same data, just with slightly different naming:

DB1: Serialnumber Productnumber DB2: SerialNumber ProductNumber Result

So I want to be able to wrap these tables in a class that will let me get back the serial number and product number regardless of the DataContext that it is coming from. I've looked into DataTableMappings, but I really have no idea where to begin. I'd also like this to work via LINQ and direct SQL queries. Again, I'd like it to be as generic as possible so I can use the same LINQ queries for the two different contexts. What is it that I am looking for?


As a start, you'd probably want to consider coding against interfaces with your business logic - that way you can pass in DB1 or DB2 objects as long as their classes implement the interfaces specified.

0

精彩评论

暂无评论...
验证码 换一张
取 消