开发者

How Does GetSchemaTable() Work?

OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader(CommandBehavior.KeyInfo);
DataTable dataTable = oleDbDataReader.GetSchemaTable();

How does GetSchemaTable() work?

Where does 开发者_StackOverflowit get its information in RDBMS?


The implementation of IDataReader.GetSchemaTable() is up to the provider - so it will vary. You can write your own providers and do it any way you want.

To be honest this is bad bit of design in the framework - you should never have interface methods that return an untyped DataTable or DataSet as that result could contain anything. Kinda defeats the point of constraining it by an interface in the first place: "you must have a method that returns DataTable but we don't care what rows or columns it has"

Even if the provider is SQL GetSchemaTable() doesn't go back to the [syscolumns] or [sysobjects]. That would be an additional DB call, require additional privileges and not work anyway, as the result set doesn't need to reflect any objects in the DB.

I'm not certain, but I'd expect the vast majority of IDataReader.GetSchemaTable() implementations to read some properties of the meta data held with the result set.


GetSchemaTable() reads the metadata on the resultset returned by ADO.NET.


From the system tables (e.g., syscolumns, sysobjects, etc) in each database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜