What is the best way to run a custom sql statement using IN from a c# linq to sql datacontext? I have tried:
db.ExecuteCommand(
"UPDATE tblCard SET used = 1 WHERE id IN ({0}) AND customer_id = {1}",
Request.Form["ids"], customer_id
);
Which is fine for 1 item passed through the form, but if i get posted through for example "2,1" then I get a sqlclient exception:
Conversion failed when converting the nvarchar value '2,1' to data type int.
If instead I use string.format to insert the parameter it works fine, but obviously this is open to sql injection.