public void T714342()
        {
            var data = System.Linq.Dynamic.Core.DynamicQueryableExtensions.Select(
                new[] { new { CategoryID = 1 } }.AsQueryable(),
                "new { CategoryID }"
                );

            Assert.False(DynamicBindingHelper.ShouldUseDynamicBinding(data.ElementType));
        }
        IEnumerable <Expression> MakeAggregates(Expression aggregateTarget, IEnumerable <SummaryInfo> summary)
        {
            foreach (var s in TransformSummary(summary))
            {
                var itemParam    = CreateItemParam(typeof(T));
                var selectorExpr = CompileAccessorExpression(itemParam, s.Selector, liftToNullable: true);
                var selectorType = selectorExpr.Type;

                var callType             = typeof(Enumerable);
                var callMethod           = GetPreAggregateMethodName(s.SummaryType);
                var callMethodTypeParams = new List <Type> {
                    typeof(T)
                };
                var callArgs = new List <Expression> {
                    aggregateTarget
                };

                if (s.SummaryType == AggregateName.COUNT_NOT_NULL)
                {
                    if (Utils.CanAssignNull(selectorType))
                    {
                        callArgs.Add(Expression.Lambda(
                                         Expression.NotEqual(selectorExpr, Expression.Constant(null, selectorType)),
                                         itemParam
                                         ));
                    }
                }
                else
                {
                    if (!IsWellKnownAggregateDataType(selectorType))
                    {
                        if (s.SummaryType == AggregateName.MIN || s.SummaryType == AggregateName.MAX)
                        {
                            callMethodTypeParams.Add(selectorType);
                        }
                        else if (s.SummaryType == AggregateName.SUM)
                        {
                            if (DynamicBindingHelper.ShouldUseDynamicBinding(typeof(T)))
                            {
                                callType   = typeof(DynamicSum);
                                callMethod = nameof(DynamicSum.Calculate);
                            }
                            else
                            {
                                selectorExpr = Expression.Convert(selectorExpr, GetSumType(selectorType));
                            }
                        }
                    }
                    callArgs.Add(Expression.Lambda(selectorExpr, itemParam));
                }

                yield return(Expression.Call(callType, callMethod, callMethodTypeParams.ToArray(), callArgs.ToArray()));
            }
        }
        Expression MakeAggregate(Expression aggregateTarget, SummaryInfo s)
        {
            var itemParam    = CreateItemParam();
            var selectorExpr = CompileAccessorExpression(itemParam, s.Selector, liftToNullable: true);
            var selectorType = selectorExpr.Type;

            var callType       = typeof(Enumerable);
            var isCountNotNull = s.SummaryType == AggregateName.COUNT_NOT_NULL;

            if (isCountNotNull && Utils.CanAssignNull(selectorType))
            {
                return(Expression.Call(
                           callType,
                           nameof(Enumerable.Sum),
                           Type.EmptyTypes,
                           Expression.Call(
                               typeof(Enumerable),
                               nameof(Enumerable.Select),
                               new[] { ItemType, typeof(int) },
                               aggregateTarget,
                               Expression.Lambda(
                                   Expression.Condition(
                                       Expression.NotEqual(selectorExpr, Expression.Constant(null, selectorType)),
                                       Expression.Constant(1),
                                       Expression.Constant(0)
                                       ),
                                   itemParam
                                   )
                               )
                           ));
            }
            else
            {
                var callMethod           = GetPreAggregateMethodName(s.SummaryType);
                var callMethodTypeParams = new List <Type> {
                    ItemType
                };
                var callArgs = new List <Expression> {
                    aggregateTarget
                };

                try {
                    if (s.SummaryType == AggregateName.MIN || s.SummaryType == AggregateName.MAX)
                    {
                        if (!IsWellKnownAggregateDataType(selectorType))
                        {
                            callMethodTypeParams.Add(selectorType);
                        }
                    }
                    else if (s.SummaryType == AggregateName.SUM)
                    {
                        if (DynamicBindingHelper.ShouldUseDynamicBinding(ItemType))
                        {
                            callType   = typeof(DynamicSum);
                            callMethod = nameof(DynamicSum.Calculate);
                        }
                        else
                        {
                            selectorExpr = ConvertSumSelector(selectorExpr);
                        }
                    }

                    if (!isCountNotNull)
                    {
                        callArgs.Add(Expression.Lambda(selectorExpr, itemParam));
                    }

                    return(Expression.Call(callType, callMethod, callMethodTypeParams.ToArray(), callArgs.ToArray()));
                } catch (Exception x) {
                    var message = $"Failed to translate the '{s.SummaryType}' aggregate for the '{s.Selector}' member ({selectorExpr.Type}). See InnerException for details.";
                    throw new Exception(message, x);
                }
            }
        }