Working with sql server metadata in c#
Are there any tools out there that encapsulate the retrieval of SQL Server metadata into a nice 开发者_运维技巧object model?
My immediate needs are to gather these things from SQL Server 2000-2008 R2:
- Databases
- Tables
- Foreign key constraints
- Triggers
So, maybe given a SqlConnection object, I could do things like this:
var dbs = conn.GetDatabases();
var db = dbs.Single(x => x.Name == "AdventureWorks");
var tables = db.GetTables();
var triggers = db.GetAllTriggers();
Of course, those examples would be very convenient, but any sort of object model would be better than what I'm doing now. Before I build my own, is there anything out there?
You might want to look at SQL Server Management Objects.
Maybe I'm missing something, but pretty much every ORM out there does this.
精彩评论