Using .SELECT with DISTINCT and List<string>. #58
-
Hello again. So what I'm trying to do is pass a list of column names that I want to use DISTINCT on. However, I can't seem to figure out how the param[] parameter works. When I call for example .SELECT("DISTINCT ", myList.ToArray()); The resulting query does not contain the array of strings that I passed into it. Also I am having trouble understanding how to go from '@p0' to 'Wisconsin' which is one of the parameter values (Not using a list in this case). Thanks again! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The params parameter is for parameter values only, not for column names. Do a simple string join: query.SELECT("DISTINCT " + string.Join(", ", myList)); |
Beta Was this translation helpful? Give feedback.
-
Ah okay, that seems like a good solution to that. I'm new to SQL so trying to learn SQL and DbExtensions at the same time is quite the task. Thanks for your help! |
Beta Was this translation helpful? Give feedback.
The params parameter is for parameter values only, not for column names. Do a simple string join: