Using Entity Framework 5 is it possible to use a stored proc with optional parameters such that you do not have to add a null for each unused parameter?
The stored p
I am demonstrating @Francisco Goldenstein comment on the answer. The order in "EXEC SP_MySP @One, @Two, @Three, @Four" statement should match your stored procedure's parameter. The order of paraOne, paraTwo, etc doesn't matter.
public List GetMyData(int thirdValue, string firstValue)
{
var paraOne = new SqlParameter("@One", firstValue);
var paraTwo = new SqlParameter("@Two", DBNull.Value);
var paraThree = new SqlParameter("@Three", thirdValue);
var paraFour = new SqlParameter("@Four", DBNull.Value);
var result = DataContext.Database.SqlQuery("EXEC SP_MySP @One, @Two, @Three, @Four"
, paraTwo, paraOne, paraFour,paraThree).ToList();
return result;
}