尝试强制SMO一次读取所有必需的字段,而不是查询访问.有关更多信息,请参阅此博客
编辑:链接已死,但我在archive.org上找到了该页面.这是相关的代码:
Server server = new Server(); // Force IsSystemObject to be returned by default. server.SetDefaultInitFields(typeof(StoredProcedure), "IsSystemObject"); StoredProcedureCollection storedProcedures = server.Databases["AdventureWorks"].StoredProcedures; foreach (StoredProcedure sp in storedProcedures) { if (!sp.IsSystemObject) { // We only want user stored procedures } }