I want a stored procedure to return multiple rows and i am using entity data model. Also i want to retrieve the value of columns of all the rows given as output.
I had done this thing using SqlDataReader, SqlCommand and SqlConnection.
SqlCommand cmd = new SqlCommand("select leave_details,LID,from_date,to_date from LeaveTable where E_ID=1 and from_date<@toDate and to_date>@fromDate", con);
cmd.Parameters.Add("@toDate", System.Data.SqlDbType.Date);
cmd.Parameters["@toDate"].Value = to_date;
cmd.Parameters.Add("@fromDate", System.Data.SqlDbType.Date);
cmd.Parameters["@fromDate"].Value = from_date;
con.Open();
obj = cmd.ExecuteReader();
And i can traverse through rows using obj.read().
And i can read value of particular column using
leave_id = (int)obj.GetValue(1);
How can i get the same thing done by a stored procedure and creating a Function Import using Entity Data Model??
There are several steps to do this I believe this is by far the best tutorial to achieve this that can be found online
http://msdn.microsoft.com/en-us/data/gg699321.aspx
you basically have to create a new complex type since you are selecting from several tables I believe this tutorial has an example on how to do this. basically you will return a set of values in a list and then you can read each value/object from alist