title: Generic procedure execution method for DAL incl. parameters
body: <p>I am trying to create a "generic" method in a data access layer that executes a passed stored procedure in Sql Server and also takes a list / array / collection of SqlParameters, to make the usage of a stored procedure call within other parts of the code easier (without requirement to care for connection, command objects etc).</p>
  
  <p>The goal is sth. like this:</p>
  
  <pre><code>int iAffectedRows = dal.RunProcedure("dbo.mySP", parameters);
  </code></pre>
  
  <p>The parameters should of course be defined previously but without the types. I want them to be created using the <code>AddwithValue()</code> method of <a href="https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparametercollection%28v=vs.110%29.aspx" rel="nofollow">SqlParameterCollection class</a>.</p>
  
  <p>It looks like it's impossible because the SqlParameterCollection class can't be instanciated. Look at this <a href="https://social.msdn.microsoft.com/Forums/en-US/3fcb546b-f2bc-4e59-b73e-c87dd47372d1/instantiating-sqlparametercollection?forum=adodotnetdataproviders&amp;prof=required" rel="nofollow">discussion</a>.</p>
  
  <p>Anyone knows how to create this?</p>