问题
Before I run off and write my own version from scratch, is there an API that exposes the system views in SQL Server (e.g. sys.tables and sys.procedures) to C#?
回答1:
As you suggest, you can use ADO.NET
to query the system catalogs.
You could also use LINQ to SQL:
Open Server Explorer in Visual Studio. Open a connection to the server.
Right-click the server and choose Change View > Object Type.
Under System Tables and User Tables, you can drag a system object onto a .dbml surface.
For database specific objects use SMO (SQL Server Management Objects)
In C# add Microsoft.SqlServer.Management.Smo
SQL Server Management Objects (SMO) Programming Guide
StoredProcedureCollection
ViewCollection
TableCollection
This might be of use: Reference Microsoft.SqlServer.Smo.dll
来源:https://stackoverflow.com/questions/25102044/is-there-a-c-sharp-api-for-sys-tables-and-sys-procedures