c# - Insert into 120 columns from 120-indexed array -
i have column names this
id ,test ,[h01_1] ,[h01_2] ,[h01_3] ,[h01_4] ,[h01] ,[h02_1] ,[h02_2] ,[h02_3] ,[h02_4] ,[h02] ,[h03_1] ,[h03_2] ,[h03_3] ,[h03_4] ,[h03] ,[h04_1] ,[h04_2] ,[h04_3] ,[h04_4] ,[h04] ,[h05_1] ,[h05_2] ,[h05_3] ,[h05_4] ,[h05] ,[h06_1] ,[h06_2] ,[h06_3] ,[h06_4] ,[h06] ,[h07_1] ,[h07_2] ,[h07_3] ,[h07_4] ,[h07] ,[h08_1] ,[h08_2] ,[h08_3] ,[h08_4] ,[h08] ,[h09_1] ,[h09_2] ,[h09_3] ,[h09_4] ,[h09] ,[h10_1] ,[h10_2] ,[h10_3] ,[h10_4] ,[h10] ,[h11_1] ,[h11_2] ,[h11_3] ,[h11_4] ,[h11] ,[h12_1] ,[h12_2] ,[h12_3] ,[h12_4] ,[h12] ,[h13_1] ,[h13_2] ,[h13_3] ,[h13_4] ,[h13] ,[h14_1] ,[h14_2] ,[h14_3] ,[h14_4] ,[h14] ,[h15_1] ,[h15_2] ,[h15_3] ,[h15_4] ,[h15] ,[h16_1] ,[h16_2] ,[h16_3] ,[h16_4] ,[h16] ,[h17_1] ,[h17_2] ,[h17_3] ,[h17_4] ,[h17] ,[h18_1] ,[h18_2] ,[h18_3] ,[h18_4] ,[h18] ,[h19_1] ,[h19_2] ,[h19_3] ,[h19_4] ,[h19] ,[h20_1] ,[h20_2] ,[h20_3] ,[h20_4] ,[h20] ,[h21_1] ,[h21_2] ,[h21_3] ,[h21_4] ,[h21] ,[h22_1] ,[h22_2] ,[h22_3] ,[h22_4] ,[h22] ,[h23_1] ,[h23_2] ,[h23_3] ,[h23_4] ,[h23] ,[h24_1] ,[h24_2] ,[h24_3] ,[h24_4] ,[h24]
and trying write simple insert dapper (sql server 2014). id , test writing anonymous object put param wasn't sure whats best way take 120 length int? array , insert columns beginning h
where index 0 goes h01_1 , index 1 goes h01_2 ... etc
i don't want have write sql says
h01_1 = @h01_1, h01_2 = @h01_2, ...
and have make anonymous object does
h01_1 = array[0], h01_2 = array[1], ...
one thing can insert id , test , go , update on record. still in same scenario before don't know best way write update in dapper without writing things out 120 times.
if possible change datatable structure follow below design
in table have more number of column , find out assigned id primary . instead of using above data structure use below ..
id test column value
01 xyz h01_1 val_h01_1
01 xyz h01_2 val_h01_2
assign group primary key id,test , column..
- if not possible changing structure . create xml front end data , create stored procedure below excute . if go through http://www.itworld.com/article/2960645/development/tsql-how-to-use-xml-parameters-in-stored-procedures.html idea.
Comments
Post a Comment