I have a stored-procedure
which accepts five parameters and performing a update on a table
Update Table
Set field = @Field
Where col1= @Para1 and Col2=@Para and Col3=@Para3 and col4 =@aPara4
From the user prospective you can select multiple values for all the condition parameters. For example you can select 2 options which needs to match Col1 in database table (which need to pass as @Para1)
So I am storing all the selected values in separates lists.
At the moment I am using foreach loop to do the update
foreach (var g in _list1)
{
foreach (var o in _list2)
{
foreach (var l in _list3)
{
foreach (var a in _list4)
{
UpdateData(g, o, l,a);
}
}
}
}
I am sure this is not a good way of doing this since this will call number of database call. Is there any way I can ignore the loop and do a minimum number of db calls to achieve the same result?
Update
I am looking for some other approach than Table-Valued Parameters