c# - Use User defined Table Type as a parameter to Stored Procedure -


i have used user-defined table type parameter in stored procedure. table type few columns.

for have generate datatable follows::

        system.data.datatable processedtable = new system.data.datatable();          processedtable.columns.add("dosid", typeof(long));         processedtable.columns.add("paylc", typeof(decimal));         processedtable.columns.add("payic", typeof(decimal)); 

in code above, ok form datatable 3 columns.

but have stored procedure requires table 30 columns.

is there better way creating datatable in c# code?

you need above code name columns should match table type. other way see use reflection iterate through properties , add columns datatable each column name same property's. but, in approach, need ensure property names , datatype column names same.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -