using stored procedure in entity framework

You need to create a model class that contains all stored procedure properties like below. Also because Entity Framework model class needs primary key, you can create a fake key by using Guid. public class GetFunctionByID { [Key] public Guid? GetFunctionByID { get; set; } // All the other properties. } then register the GetFunctionByID … Read more

Get return value from stored procedure

I found it! I can read the return value with an output parameter that has to be used in this way: // define a new output parameter var returnCode = new SqlParameter(); returnCode.ParameterName = “@ReturnCode”; returnCode.SqlDbType = SqlDbType.Int; returnCode.Direction = ParameterDirection.Output; // assign the return code to the new output parameter and pass it to … Read more

Difference between Parameters.Add(string, object) and Parameters.AddWithValue

There is no difference in terms of functionality. In fact, both do this: return this.Add(new SqlParameter(parameterName, value)); The reason they deprecated the old one in favor of AddWithValue is to add additional clarity, as well as because the second parameter is object, which makes it not immediately obvious to some people which overload of Add … Read more