Пример #1
0
        protected virtual bool ValidateInvoke(InvokeInfo invokeInfo)
        {
            var required = MethodInfo.Parameters.Where(x => x.IsRequired).ToDictionary(x => x.Name, y => y);

            foreach (var param in required)
            {
                if (!invokeInfo.HasArgument(param.Key))
                {
                    return(false);
                }

                if (!param.Value.IsDeterministic)
                {
                    var argType = invokeInfo.ArgumentType(param.Key);
                    if (!param.Value.ParameterType.IsComparable(argType))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #2
0
        protected virtual SqlType DetermineReturnType(InvokeInfo invokeInfo)
        {
            SqlType resultType = null;

            foreach (var name in invokeInfo.ArgumentNames)
            {
                var argType = invokeInfo.ArgumentType(name);
                if (resultType == null)
                {
                    resultType = argType;
                }
                else
                {
                    resultType = argType.Wider(resultType);
                }
            }

            if (resultType == null)
            {
                throw new MethodException($"Unable to determine the return type of function {MethodInfo.MethodName}");
            }

            return(resultType);
        }