title: Using DbParameter instead of SqlParameter with _context.Database.SqlQuery for stored proc execution
body: <p>I am using Entity Framework 6.1 and GenericRepository. To execute stored procedure I am using SqlQuery method. Currently I am using SqlParameters but being a GenericRepository I don't want to use some specific class. I tried multiple options but how can I use DbParameter here. I tried to access providerName (System.Data.SqlClient) from dbcontext but that is also not available. Any direction would help. Please let me know incase you want me to provide more informaiton.</p>
  
  <pre><code>    public IEnumerable&lt;T&gt; GetAllFromStoredProcedure(string storedProcedureName, List&lt;StoredProcedureParameter&gt; parameters)
      {
          List&lt;SqlParameter&gt; sqlParameters = new List&lt;SqlParameter&gt;();
  
          foreach (StoredProcedureParameter parameter in parameters)
          {
              sqlParameters.Add(new SqlParameter(parameter.Name, parameter.Type) { Value = parameter.Value});
          }
  
          return _context.Database.SqlQuery&lt;T&gt;(storedProcedureName, sqlParameters.ToArray());
      }
  </code></pre>
  
  <p>calling as -</p>
  
  <pre><code>    clientRepository.GetAllFromStoredProcedure("GetClients", parameters).ToList();
  </code></pre>