I need some guidance with an issue, I am using Entity Framework 4.0, I have a DAL and BLL and am binding to ObjectDataSource on the page.
I had to write a stored pr
If you already have an Entity type that matches your proc return type, use it as the type parameter.
public List GetData(int product_id) where T : class
{
List myList = new List();
var groupData = context.ExecuteStoreQuery("exec
spGetProductsByGroup @ProductID={0}", product_id);
return myList;
}
Otherwise you could use an ADO.NET DataReader to build the list manually.
using (SqlConnection connection = new SqlConnection("your connection string"))
{
SqlCommand command = new SqlCommand(
"exec spGetProductsByGroup @ProductID",
connection);
command.Parameters.Add(product_id);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
List list = new List();
if (reader.HasRows)
{
while (reader.Read())
{
list.Add(new ProcType(){Property1 = reader.GetInt32(0), Property1 = reader.GetString(1));
}
}
reader.Close();
return list;
}