I have a table named Variables
which has (Id ,AdId,Variable1,Variable2,Variable3,Variable4,Variable5,Variable6,Variable7,Variable8 )
, and I have a List<string> a
which contains a number of strings (maybe 1,3,6,or 8).
My question is how to insert these strings in the List to the Variables table?
I can do such a thing
Variables v=new Variables();
v.AdId=2;
if(a.count()==1){
v.variable1=a[0];
}else if(a.count()==2){
v.variable1=a[0];
v.variable2=a[1]
}else if (//so on){}
But
I want to do something more dynamically like so:
Variables v=new Variables();
v.AdId=2;
for(int i=0; i<a.count() ;i++)
{
//here list items to be inserted to (variable1,variable2.....variable8)
//, depending on list size ,number of variables are inserted
}