Getting .NET schema for a stored procedure result
Posted
by PHeiberg
on Stack Overflow
See other posts from Stack Overflow
or by PHeiberg
Published on 2010-04-30T11:38:54Z
Indexed on
2010/04/30
11:57 UTC
Read the original article
Hit count: 219
I have a couple of stored procedures in T-SQL where each stored procedure has a fixed schema for the result set.
I need to map the result sets for each procedure to a POCO object and need the column name and type for each column in the result set. Is there a quick way of accessing the information?
The best way I have found so far is accessing each stored procedure from .NET and writing my own extension method on a IDataReader/IDataRecord for dumping the information (column names and types) out.
Example, a stored procedure executing the following query:
SELECT Id, IntField, NullableIntField, VarcharField, DateField FROM SomeTable
would require me to have the mapping information:
Id - Guid
IntField - System.Int32
NullableIntField - Nullable<System.Int32>
VarcharField - String
DateField - DateTime
© Stack Overflow or respective owner