开发者

How to generate typed datasets for multiple database platforms?

I want to generate a typed DataSet for both Oracle and DB2 databases from a single XSD file.

Background: When I drag a table onto the Visual Studio Dataset Designer, it generates a XSD file (e.g. DataSet1.xsd) with all appropriate information. Then VS invokes the built-in Tool (MSDataSetGenerator) to generate the Dataset classes into the CS file. Somehow (I don't know how) CS determines the Data provider and generates Data开发者_如何学运维set classes that refer to the data provider (OracleDataProvider or IBM.Data.Provider).

Question: Does anybody know how I can customize VS to compile both for DB2 and Oracle code generation ?

Best regards Oliver


Hi the problem is not in the structure of the data (set,tables).
It's the automatically generated adapters that create a dependency on the database/connection.

The first way to circumvent this (a bit) is using ODBC connections for your adapters.
Then the connectionstring determines which database you use..
However.. the SQL syntax is always a little different.


Personally I just make a DataSet.xsd with only datatables (new datatable instead of new dataadapter).

Then I write my own repositories/adapters myself. So one for oracle and one for DB2.
These repositories/adapters fill the datatables..

So you can share the model between databases but you implement database specific adapters.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜