Build a dynamic GroupBy with Linq V3

With the legacy Linq driver we use constructs such as below:

.GroupBy(s => new
                    TimeContainer = statisticsRequest.AggregateTime ? (DateTime?)null : s.TimeContainer,
                    PublisherId = statisticsRequest.AggregatePublishers ? (Guid?)null : s.PublisherId,
                    BuyerId = statisticsRequest.AggregateBuyers ? (Guid?)null : s.BuyerId,
                .Select(s => new CombinedStats()
                    From = s.Min(x => x.TimeContainer),
                    To = s.Max(x => x.TimeContainer),
                    PublisherId = s.Key.PublisherId,
                    BuyerId = s.Key.BuyerId,
                    Request = new RequestStats()
                        BuyerRequests = s.Sum(x => x.Requests),

However, with, building a dynamic GroupBy seems to break (giving an IIF error).

I haven’t found a way to build a dynamic group by without massive rewrites. Does anyone know of a solution to this?

The error given is System.InvalidOperationException: Cannot find serializer for IIF(True, Convert(s.PublisherId, Nullable`1), null)