Beispiel #1
0
        private int HandleExec(DataSet db, DbCommand cmd)
        {
            var prms = _mi.GetParameters();

            List <object> parameter_values = new List <object>();

            parameter_values.Add(db);
            if (prms.Length == 2 && prms[1].ParameterType == typeof(DbCommand))
            {
                parameter_values.Add(cmd);

                if (wrapped_compiledMethod_Exec == null)
                {
                    wrapped_compiledMethod_Exec = CommandExecutionHandlerImpl.CollectCommandHandlerMethod_NonQuery(_mi, _instanceType);
                }

                if (_mi.IsStatic)
                {
                    return(wrapped_compiledMethod_Exec(db, cmd));
                }
                else
                {
                    return(wrapped_compiledMethod_Exec(db, cmd));
                    //throw new NotImplementedException("public DbDataReader " + _mi.Name + "(DataSet db, DbCommand cmd) of '" + _instanceType.Name + "'");
                }
            }
            else
            {
                List <object> invoke_parameters = new List <object>();
                invoke_parameters.Add(db);

                StringBuilder debug_params = new StringBuilder();
                for (int ix = 1; ix < prms.Length; ix++)
                {
                    ParameterInfo method_prm = prms[ix];
                    var           cmd_prm    = cmd.Parameters[method_prm.Name];

                    object prm_value = GetTypedCommandParameter(cmd, method_prm);
                    invoke_parameters.Add(prm_value);

                    string debug_method_prm; debug_method_prm = TypeNameAsText(method_prm.ParameterType);
                    debug_params.Append(", " + debug_method_prm + " " + method_prm.Name);
                }

                if (_mi.IsStatic)
                {
                    object returnValues = _mi.Invoke(null, invoke_parameters.ToArray());
                    return(returnValues == null ? 0 : (int)returnValues);
                }
                else
                {
                    object handlerInstance = Activator.CreateInstance(this._instanceType);
                    object returnValues    = _mi.Invoke(handlerInstance, invoke_parameters.ToArray());

                    return(returnValues == null ? 0 : (int)returnValues);
                    //string debug_ret; debug_ret = TypeNameAsText(_mi.ReturnType);
                    //throw new NotImplementedException("public " + debug_ret + " " + _mi.Name + "(DataSet db" + debug_params.ToString() + ") of '" + _instanceType.Name + "'");
                }
            }
        }
Beispiel #2
0
        private DbDataReader HandleRead(DataSet db, DbCommand cmd)
        {
            var prms = _mi.GetParameters();

            List <object> parameter_values = new List <object>();

            parameter_values.Add(db);
            if (prms.Length == 2 && prms[1].ParameterType == typeof(DbCommand))
            {
                parameter_values.Add(cmd);

                if (wrapped_compiledMethod_Read == null)
                {
                    wrapped_compiledMethod_Read = CommandExecutionHandlerImpl.CollectCommandHandlerMethod_Query(_mi, _instanceType);
                }

                if (_mi.IsStatic)
                {
                    return(wrapped_compiledMethod_Read(db, cmd));
                }
                else
                {
                    return(wrapped_compiledMethod_Read(db, cmd));
                    //throw new NotImplementedException("public DbDataReader " + _mi.Name + "(DataSet db, DbCommand cmd) of '" + _instanceType.Name + "'");
                }
            }
            else
            {
                List <object> invoke_parameters = new List <object>();
                invoke_parameters.Add(db);

                StringBuilder debug_params = new StringBuilder();
                for (int ix = 1; ix < prms.Length; ix++)
                {
                    ParameterInfo method_prm = prms[ix];
                    var           cmd_prm    = cmd.Parameters[method_prm.Name];

                    object prm_value = GetTypedCommandParameter(cmd, method_prm);
                    invoke_parameters.Add(prm_value);

                    string debug_method_prm; debug_method_prm = TypeNameAsText(method_prm.ParameterType);
                    debug_params.Append(", " + debug_method_prm + " " + method_prm.Name);
                }

                if (_mi.IsStatic)
                {
                    object      returnValues  = _mi.Invoke(null, invoke_parameters.ToArray());
                    DataTable[] result_tables = CreateDbDataReaderFromSingleSetReturnValues(_mi.ReturnType, returnValues); // single/multiple result set(from dibix); enumerable or not; complex or not(names for columns?(from SQL/accessor))
                    return(new DataTableReader(result_tables));
                }
                else
                {
                    object handlerInstance = Activator.CreateInstance(this._instanceType);
                    object returnValues    = _mi.Invoke(handlerInstance, invoke_parameters.ToArray());

                    DataTable[] result_tables = CreateDbDataReaderFromSingleSetReturnValues(_mi.ReturnType, returnValues); // single/multiple result set(from dibix); enumerable or not; complex or not(names for columns?(from SQL/accessor))
                    return(new DataTableReader(result_tables));
                    //string debug_ret; debug_ret = TypeNameAsText(_mi.ReturnType);
                    //throw new NotImplementedException("public " + debug_ret + " " + _mi.Name + "(DataSet db" + debug_params.ToString() + ") of '" + _instanceType.Name + "'");
                }
            }
        }
Beispiel #3
0
 internal override Func <DataSet, DbCommand, DbDataReader> DoCompileReadMethod()
 {
     return(CommandExecutionHandlerImpl.CollectCommandHandlerMethod_Query(MethodCallExpr.Method, HandlerMethodOwner));
 }