📜  按表达式动态分组 C# 代码示例

📅  最后修改于: 2022-03-11 14:48:57.810000             🧑  作者: Mango

代码示例1
private static Expression> GetGroupKey(string property)
{
    var parameter = Expression.Parameter(typeof(Menu));
    var body = Expression.Property(parameter, property);
    return Expression.Lambda>(body, parameter);
}

// Usage
context.Menus.GroupBy(GetGroupKey(columnName));