从 ADO.NET 字段获取表名?

发布于 2024-08-17 18:30:05 字数 207 浏览 1 评论 0原文

如果我对 user.name、user.post、t.name 进行选择,其中 t 为 tag_name AS t,有没有办法使用 ADO.NET 解析全名?

我找到了 SqlDataReader.GetName 但这只让我得到 name 作为第一个结果。我想知道它是属于 user 还是 tag_name。有什么办法让它告诉我吗?

If i do a select on user.name, user.post, t.name with t being tag_name AS t is there a way to resolve the full name using ADO.NET?

I found SqlDataReader.GetName but that is getting me only name as the first result. I would like to know if it belongs to user or tag_name. Is there a way to have it tell me?

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

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

发布评论

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

评论(3

じ违心 2024-08-24 18:30:05

当结果返回到 ado.net 时,字段的原始源表已经消失 - 您所拥有的只是字段名称。

By the time the results get back to ado.net, the original source table of the fields are gone - all you have are the field names.

浅暮の光 2024-08-24 18:30:05

您可以使用表名作为前缀为字段别名,并读取字段名并在客户端中对其进行操作。

select a.column1 as [users column1],b.column2 as [tag_name column2] from users a     left join tag_name b on a.col = b.col blah blah....

You could alias your field with the table name as a prefix and read the fieldname and manipulate it in the client..

select a.column1 as [users column1],b.column2 as [tag_name column2] from users a     left join tag_name b on a.col = b.col blah blah....
合久必婚 2024-08-24 18:30:05

Ray 是正确的,ado.net 不会给你这个。我过去所做的就是从存储过程或视图中获取 SQL,并进行一些字符串操作来解决这个问题。

Ray is correct in that ado.net doesn't give you this. What I have done in the past is to get the SQL from the stored procedure or view and do some string manipulation to work this out.

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