Surely there is a framework method that given an array of integers, strings etc converts them into a list that can be used in a SQL "IN
" clause?
e.g.
int[] values = {1,2,3};
would go to
"(1,2,3)"
var inClause = "("
+ String.Join(",", values.Select(x => x.ToString()).ToArray())
+ ")";
Note: You no longer need to call .ToArray()
in .NET Framework 4. A new String.Join<T>(string separator, IEnumerable<string> values)
method is added.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With