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;
今、グループクローセルでifクエリを実行したいと考えています。多分文字列の助けを借りて
string groupClausel = "Name";
または列挙:
public enum FilterMethod
{
Directory,
CreationTime,
DirectoryName,
Extension,
Length,
Name
}
しかし、group-clauselで文字列または列挙型をチェックする方法がわかりません。次のような構文があることは知っています
group info by (groupClausel == "Extension" ? info.Extension : info.Name) into g
しかし、これにより、2 つの属性を選択することができます...
アイデアはありますか?