internal static DbExpressionList ValidateFunctionAggregate( EdmFunction function, IEnumerable <DbExpression> args) { ArgumentValidation.CheckFunction(function); if (!TypeSemantics.IsAggregateFunction(function) || function.ReturnParameter == null) { throw new ArgumentException(Strings.Cqt_Aggregate_InvalidFunction, nameof(function)); } FunctionParameter[] expectedParams = ArgumentValidation.GetExpectedParameters(function); return(ArgumentValidation.CreateExpressionList(args, "argument", expectedParams.Length, (Action <DbExpression, int>)((exp, idx) => { TypeUsage typeUsage = expectedParams[idx].TypeUsage; TypeUsage elementType = (TypeUsage)null; if (TypeHelpers.TryGetCollectionElementType(typeUsage, out elementType)) { typeUsage = elementType; } ArgumentValidation.RequireCompatibleType(exp, typeUsage, "argument"); }))); }
internal static TypeUsage ValidateFunction( EdmFunction function, IEnumerable <DbExpression> arguments, out DbExpressionList validArgs) { ArgumentValidation.CheckFunction(function); if (!function.IsComposableAttribute) { throw new ArgumentException(Strings.Cqt_Function_NonComposableInExpression, nameof(function)); } if (!string.IsNullOrEmpty(function.CommandTextAttribute) && !function.HasUserDefinedBody) { throw new ArgumentException(Strings.Cqt_Function_CommandTextInExpression, nameof(function)); } if (function.ReturnParameter == null) { throw new ArgumentException(Strings.Cqt_Function_VoidResultInvalid, nameof(function)); } FunctionParameter[] expectedParams = ArgumentValidation.GetExpectedParameters(function); validArgs = ArgumentValidation.CreateExpressionList(arguments, nameof(arguments), expectedParams.Length, (Action <DbExpression, int>)((exp, idx) => ArgumentValidation.RequireCompatibleType(exp, expectedParams[idx].TypeUsage, nameof(arguments), idx))); return(function.ReturnParameter.TypeUsage); }