Is there a C# API for sys.tables and sys.procedures?

南楼画角 提交于 2019-12-13 02:30:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!