Reputation: 538
What are database vendor independent ways to obtain list of tables in C# code?
I heard about three:
IDbConnection.GetSchema("Tables")
new System.Data.Linq.DataContext(IDbConnection).Mapping.GetTables();
(>=3.5, System.Data.Linq.dll).But this mean that somewhere there are a set of adapters for syntax of each vendor.
Is there a standard SQL syntax for this operation?
What are other ways to get list of tables in C#?
Upvotes: 2
Views: 2141
Reputation: 176314
You could use ANSI standard Information Schema Views:
SELECT *
FROM INFORMATION_SCHEMA.TABLES;
Supported by: SQL Server, Postgresql, MySQL, ...
Not implemented by Oracle, DB2, SQLite,...
Upvotes: 4