Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

dynamic group by expression C#

private static Expression<Func<Menu, string>> GetGroupKey(string property)
{
    var parameter = Expression.Parameter(typeof(Menu));
    var body = Expression.Property(parameter, property);
    return Expression.Lambda<Func<Menu, string>>(body, parameter);
}

// Usage
context.Menus.GroupBy(GetGroupKey(columnName));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dynamic #group #expression
ADD COMMENT
Topic
Name
1+3 =