Get table name from ADO.NET Field?
If i do a select on user.name, user.post, t.name with t be开发者_如何学JAVAing 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?
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..
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....
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.
精彩评论