GetSchemaTable() 如何工作?

发布于 2024-08-07 17:20:35 字数 239 浏览 1 评论 0原文

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

GetSchemaTable() 是如何工作的?

它从 RDBMS 中哪里获取信息?

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

How does GetSchemaTable() work?

Where does it get its information in RDBMS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

醉殇 2024-08-14 17:20:35

IDataReader.GetSchemaTable() 的实现取决于提供者 - 因此会有所不同。您可以编写自己的提供程序并按照您想要的方式进行操作。

老实说,这是框架中的一个糟糕的设计 - 您永远不应该使用返回非类型化 DataTableDataSet 的接口方法,因为该结果可能包含任何内容。有点挫败了通过接口来约束它的要点:“你必须有一个返回 DataTable 的方法,但我们不关心它有哪些行或列” >

即使提供程序是 SQL GetSchemaTable() 也不会返回到 [syscolumns][sysobjects]。这将是一个额外的数据库调用,需要额外的权限,并且无论如何都不起作用,因为结果集不需要反映数据库中的任何对象。

我不确定,但我希望绝大多数 IDataReader.GetSchemaTable() 实现能够读取结果集保存的元数据的某些属性。

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.

双手揣兜 2024-08-14 17:20:35

GetSchemaTable() 读取 ADO.NET 返回的结果集上的元数据。

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

千鲤 2024-08-14 17:20:35

来自每个数据库中的系统表(例如,syscolumns、sysobjects 等)。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文