コード例 #1
0
        internal void Validate(SqlMethod method, IContext context)
        {
            var methodInfo = method.MethodInfo;

            if (method.IsFunction && !HasReturnedValue)
            {
                throw new MethodException($"The execution of function {methodInfo.MethodName} has no returned value");
            }

            var output = methodInfo.Parameters.Where(x => x.IsOutput);

            foreach (var requestedParam in output)
            {
                SqlExpression outputValue;
                if (!Output.TryGetValue(requestedParam.Name, out outputValue))
                {
                    throw new MethodException($"The requested output parameter {requestedParam.Name} was not set by the method {methodInfo.MethodName}");
                }

                var outputType = outputValue.GetSqlType(context);
                if (!outputType.IsComparable(requestedParam.ParameterType))
                {
                    throw new MethodException($"The value set for output parameter {requestedParam.Name} is invalid");
                }
            }
        }
コード例 #2
0
        internal MethodContext(IContext context, SqlMethod method, Invoke invoke)
            : base(context, $"Method({method.MethodInfo.MethodName})")
        {
            Invoke = invoke;
            Method = method;

            namedArgs = BuildArguments(method.MethodInfo, invoke);

            ResultValue = SqlExpression.Constant(SqlObject.Null);
            output      = new Dictionary <string, SqlExpression>();

            Metadata = new Dictionary <string, object>();
        }
コード例 #3
0
        internal MethodContext(IContext context, SqlMethod method, Invoke invoke)
            : base(context, method.Type == MethodType.Function ? "function" : "procedure")
        {
            Invoke = invoke;
            Method = method;

            namedArgs = BuildArguments(method.MethodInfo, invoke);

            ResultValue = SqlExpression.Constant(SqlObject.Null);
            output      = new Dictionary <string, SqlExpression>();

            Metadata = new Dictionary <string, object>();
        }
コード例 #4
0
        public void Register(SqlMethod method, params ObjectName[] aliases)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            var methodName = method.MethodInfo.MethodName.ToUpper();

            container.RegisterInstance <SqlMethod>(method, methodName);

            foreach (var alias in aliases)
            {
                container.RegisterInstance <SqlMethod>(method, alias.ToUpper());
            }

            initialized = false;
        }