public string PROCEDURE_ACTION(IConnectToDB _Connect, string ProcedureName, List <DBParameters> EntryProcedureParameters, string _ReturnParameter) { List <DBParameters> ParamListDynamic = new List <DBParameters>(); switch (_Connect.Platform.ToLower()) { case "microsoft": Paramatizer(EntryProcedureParameters, ParamListDynamic); BIG_CALL RUN = new BIG_CALL(); RUN.COMMANDS = new List <SQL_PROCEDURE_CALL>(); RUN.COMMANDS.Add(new SQL_PROCEDURE_CALL { ProcedureType = "value", ProcedureName = ProcedureName, _dbParameters = ParamListDynamic }); DataTable _result = ER_Procedure.SQL_PROCEDURE_PARAMS(_Connect, RUN).COMMANDS[0].result._DataTable; return(ER_Procedure.SQL_PROCEDURE_GET_VALUE("@" + _ReturnParameter, _result)); default: return("Invalid DB Platform"); } }
private static void RunGeneratedCommand(IConnectToDB _Connect, T thisModel, SQLProcedureModels.BIG_CALL RUN) { DataTable _result = ER_Procedure.SQL_PROCEDURE_PARAMS(_Connect, RUN).COMMANDS[0].result._DataTable; //DataRow[] outputRow = _result.Select("ID = " + outputParam); string attemptedSQL = _result.Rows.Count > 0 && _result.Rows[0].Field <string>("ChildSQL") != null ? _result.Rows[0].Field <string>("ChildSQL").ToString() : ""; bool isError = _result.Rows.Count > 0 && _result.Rows[0].Field <string>("ChildType") != null && _result.Rows[0].Field <string>("ChildType").ToString() == "Error"; if (!String.IsNullOrWhiteSpace(attemptedSQL)) { thisModel.GetType().GetProperty("V_ATTEMPTED_SQL")?.SetValue(thisModel, attemptedSQL, null); } if (isError) { try { thisModel.GetType().GetProperty("O_ERR_MESS")?.SetValue(thisModel, _result.Rows[0].Field <string>("ChildValue").ToString(), null); } catch (Exception) { } } else { foreach (DataRow row in _result.Rows) { var modelProperty = row["ChildItem"].ToString().Replace("@", ""); var thisValue = row["ChildValue"]; if (modelProperty.Substring(0, 2) == "O_") { var propertyType = thisModel.GetType().GetProperty(modelProperty)?.PropertyType; object propertyVal = row["ChildValue"]; if (propertyType != null) { //propertyVal = Convert.ChangeType(thisValue, propertyType); propertyVal = ChangeType(propertyVal, propertyType); } if (propertyVal != null) { thisModel.GetType().GetProperty(modelProperty)?.SetValue(thisModel, propertyVal, null); } } //if (row.ItemArray[2].ToString() == ReturnValueFor && Int64.TryParse(row.ItemArray[3].ToString(), out outputid)) //{ // thisModel.GetType().GetProperty(outputParam).SetValue(thisModel, outputid, null); //} } } }