Get Dynamic LINQ and use the extension from which you can specify keySelector with a string.
var query = db.Foo.GroupBy( "{0}", "GroupedProperty", groupKey );
You may also want to add your own extension if you want to return the entire object grouped by key.
public static IQueryable GroupByComplete( this IQueryable source, string keySelector, params object[] values ) { if (source == null) throw new ArgumentNullException( "source" ); if (keySelector == null) throw new ArgumentNullException( "keySelector" ); LambdaExpression keyLambda = DynamicExpression.ParseLambda( source.ElementType, null, keySelector, values ); return source.Provider.CreateQuery( Expression.Call( typeof( Queryable ), "GroupBy", new Type[] { source.ElementType, keyLambda.Body.Type }, source.Expression, Expression.Quote( keyLambda ) ) ); }
source share