Is it possible to get the number of parameters being passed to a method in run time, and if so how?
For instance, if if would be possible, I could have a database interaction method as follows,
public void AddSomethingToDatabase(string parameter1, string parameter2)
{
...
foreach(param in parameters)
{
sp.AddParameter(GetName(param),param));
}
conn.Execute(...);
}
I am attempting to not have to add/change a line in code each time my stored procedure parameters change, instead only changing the method signature with the correct stored procedure parameters. In this case, parameter1
and parameter2
would be the actual names of the parameters in the stored procedure. Any ideas?