开发者

One Set of POCO classes with interchangeable databases

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜