internal static IQueryable <IGrouping <TKey, T> > GroupBy <T, TKey>(this IQueryable <T> queryable, Expression <Func <T, TKey> > filter) { if (queryable is IMongoQueryable <T> mongoQueryable) { return(MongoQueryable.GroupBy(mongoQueryable, filter)); } return(Queryable.GroupBy(queryable, filter)); }