Backstory:
So I have a little demo application I'm working on which is looking through songs and trying to find duplicates based on tags the user specifies. Initially I was just using the below query which I'm trying to generalize.
var query = MusicFiles.GroupBy(x =>
new { x?.Tag.FirstArtist, x?.Tag.Title }
).Where(g => g.Count() > 1)
.ToList();
Now though I want to have the user specify these properties so I used reflection to get all properties of the TagLib.Tag
class and now allow the user to specify the tags they are interested in.
Question:
How can I use this new list of strings representing the properties of the class and group by all of these properties alternatively how can I generalize the above line of code.
My initial train of thought and what I've tried has been to try and create an anonymous object like above and use reflection to get each property, but since I'm iterating over a list of string properties I end up with an anonymous object for each property rather than an anonymous object of all properties selected