Ling to SQL Generic ExcuteMethodCall with parameters
-
Hi, I would like help with writing a generic ExecuteMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters) that can take any number of input parameters and always 3 output parameters or is there another way to read output parameters because the help on ExecuteMethod call says "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code." public class MyClass { ..... [Function(Name = "sp_Info_Change")] public bool Change() { int inVal1 = 1; string inVal2 = "Test"; int outVal1 = 0; string outVal2 = ""; string outVal3 = ""; return MyDataClass.ExecuteMethod(this, (MethodInfo)MethodInfo.GetCurrentMethod(), inVal1, inVal2, ref outVal1, ref outVal2, ref outVal3); } ..... } public class MyDataContextClass: DataContext { ..... public bool ExecuteMethod(object tableClass, MethodInfo method, [Parameter(DbType = "Int")] int inVal1, [Parameter(DbType = "Varchar(25)")] string inVal2, [Parameter(DbType = "Int")] ref int outVal1, [Parameter(DbType = "Varchar(500)"] ref string outVal2, [Parameter(DbType = "Varchar(25)")] ref string outVal3) { bool result = false; IExecuteResult xresult = ExecuteMethodCall(tableClass, method, inVal1, inVal2, outVal1, outVal2, outVal3); outVal1 = Convert.ToInt32(xresult.GetParameterValue(2).ToString()); outVal2 = xresult.GetParameterValue(3).ToString(); outVal3 = xresult.GetParameterValue(4).ToString(); if (outVal1 == 1) { result = true; } return result; } } Any help would be much appreciated Thank you