简体   繁体   中英

Creating Generic MySQL SELECT Statement in C#

There are a few similar questions, but none of them seem to answer my problem. In my application I use lots of different SELECT queries and I don't want to write a method for every one, so I'm trying to create a generic one that I can just pass the specific parameters in. This is the specific example that I'm trying to modify: SELECT Statement This is my attempt at generalising it: Generic SELECT Statement I have considered trying to split up columns string by the comma delimiter, using list or arrays, but I can't work out how to solve this issue. The specific bit that I want help with is the line with the error ("cannot convert from 'System.Collections.Generic.List' to 'int'"), but I don't know enough about data readers to fix it...

Any help would be greatly appreciated.

I have a doubt, why do you need to pass columnNames as array of List<string> . array is not needed what I feel. Try passing just the List or array of string and let me know if it worked...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM