I'm looking for a tool that provides an API (preferably .Net) for querying the schema of multiple database platforms. I'm building a piece of software 开发者_JAVA百科that would take the object model returned from such a tool and then analyse the schema and provide a custom query builder - I'd prefer to not have to write the schema analysis tool if I can avoid this.
Ideally it should be able to query all the major database platforms including MSSQL, Oracle, DB2, MySQL and possibly even Sybase. The Red Gate Schema Compare SDK does exactly what I need, but only for MSSQL.
Has anyone come across such a tool/library?
I am not 100% sure, but wouldn't the Mono project contain the code you are looking for? If not for all databases, than I would expect at least for some of them.
Short answer, No.
Long answer.
I was looking to this myself a while ago but didn't find a free .Net API. All the ones I found cost money. I came up with two options
The first one is not a solution I recommend, but an option if you really don't want to write the "get DB metadata logic" yourself.
Visual query builder http://www.query-objects.com/ is a .Net query builder with a GUI. You could buy the source code license for it. Owning the source your can remove the UI and build your own API on top of that source code. It should work for MSSql, Oracle, MySql, and I guess any DB that supports ODBC.
The second and free solution is to try and write it yourself using this tutorial for example:
http://www.dotnetbips.com/articles/bcd9065e-94af-4063-8360-f916571f9872.aspx
The ADO.Net GetSchema method used here should give you a somewhat consistent way to get the Metadata from the different databases you mention.
精彩评论