开发者

One Set of POCO classes with interchangeable databases

开发者 https://www.devze.com 2023-02-03 01:01 出处:网络
I have an application that uses a set of tables to store data. 开发者_开发百科Based on client requirements they can use either Oracle or SQL Server.

I have an application that uses a set of tables to store data.

开发者_开发百科

Based on client requirements they can use either Oracle or SQL Server.

Is there a way I can create all the POCO classes that represent the tables and then somehow when the Save() method is called it updates the correct database?

So for example:

Person p = new Person;
p.Name = "John";
p.Save(); //This saves it to the database but somehow it knows to use a Oracle connection or SQL Connection

UPDATE: I have just read that the Entity Framework 4 supports multiple databases but previous versions there was a lot of bloat with it so I'm a bit put off by it and not sure whether this would provide me what I want.


If I have this kind of requirement I will use some ORM which works with POCOs (preferably using Repository Pattern like Subsonic). Then you can just change connection in configuration file or use IOC to init the ORM with correct context.

0

精彩评论

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

关注公众号