i have the following code which groups a list of FileInfos:
var group_infos =
from info in fileInfos
where info.Length < 1024 * 1024
group info by info.Name into g
where g.Count() > 1
orderby g.Count() descending, g.Key
select g;
Now i want to do an if-query on the group-clausel. Maybe with help of a string
string groupClausel = "Name";
or enum:
public enum FilterMethod
{
Directory,
CreationTime,
DirectoryName,
Extension,
Length,
Name
}
But i dont know how to check the string or enum in group-clausel.. I know there s a syntax like
group info by (groupClausel == "Extension" ? info.Extension : info.Name) into g
But this let me just select on two attributes...
Do you people have an idea?