I'm really new to C# and currently building a "Dynamic SQL string" in C#. The func should be able to construct a query string depending on parameters. My approach is looping the parameters, check conditions and append it to a query string.
logic looks like below:
forEach (int i in dataSet)
{
switch(i)
{
case 1:
sql += "ABC = "+ i;
break;
...
}
}
I'm wondering if there is any better approach(or pattern) to optimize this?
Aucun commentaire:
Enregistrer un commentaire