从 ADO.NET 字段获取表名?
如果我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当结果返回到 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.
您可以使用表名作为前缀为字段别名,并读取字段名并在客户端中对其进行操作。
You could alias your field with the table name as a prefix and read the fieldname and manipulate it in the client..
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.