I have a query that looks something like this:
SELECT foo FROM bar where bar.Id in (1,2,3);
I would like to pass the Id list as a single parameter with IDbDataParameter where the request is formatted:
SELECT foo FROM bar where bar.Id in (?ListOfID);
and then have one parameter, which is a list, and not do something like this:
SELECT foo FROM bar where bar.Id in (?id1, ?id2, ?id3);
I know that this is possible in other data providers, can I do this with the standard System.Data classes?
PS the reason why I want it to be as one parameter of the list, and not a series of parameters, is that as the number of parameters changes, MySQL will consider the query as new, and we will lose some of the caching optimizations. MySQl basically ends with a single request for the number of identifiers. This is the same reason I just don't want to manipulate the underlying SQl as a string, because then I get one request per VAULE, and that would be worse.
ryber source share