Hi I have one query that is made in sql server as below and the sp name is as sp_StudentRequest
Select DISTINCT SR.StudentRequestId,SR.RegistrationId,SR.Location,SR.PaymentMethod,SR.CreatedOn,C.ClassName,CC.CampusName,
CASE WHEN ISNULL(TSR.StatusId,0)=0 THEN 1 ELSE TSR.StatusId END AS StatusId,
substring(
(
Select ', '+REPLACE(REPLACE(ST1.FromTime,'AM',''),'PM','')+'-'+ST1.ToTime AS [text()]
From dbo.StudentRequestTimings ST1
Where ST1.StudentRequestId = SRT.StudentRequestId
ORDER BY ST1.CreatedOn
For XML PATH ('')
), 2, 1000) [Time]
FROM StudentRequest SR
Inner JOIN Registration R ON R.RegistrationId=SR.RegistrationId
INNER JOIN Campus CC ON CC.CampusId=R.CampusId
INNER JOIN Class C ON C.ClassId=SR.ClassId
LEFT JOIN TutorClasses TC ON SR.ClassId=TC.ClassId
LEFT JOIN StudentRequestTimings SRT ON SR.StudentRequestId=SRT.StudentRequestId
LEFT JOIN TutorStudentRequest TSR ON TSR.StudentRequestId=SRT.StudentRequestId AND TutorId=@RegistrationId
where TC.RegistrationId=@RegistrationId
ORDER BY SR.CreatedOn DESC
and I am calling this code from controller as
public ActionResult TutorDashboard(int? page)
{
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("sp_StudentRequest"))
{
DataSet GetData = new DataSet();
cmd.Connection = con;
con.Open();
cmd.Parameters.AddWithValue("@Operation", "GetTutorRequestDetail");
cmd.Parameters.AddWithValue("@RegistrationId", 1);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(GetData);
if (GetData.Tables[0].Rows.Count > 0)
{
ViewBag.TutorRequest = GetData.Tables[0].ToPagedList(page ?? 1, 1);
}
con.Close();
}
}
return View(ViewBag.TutorRequest);
}
Now I need tom implement the paging in MVC with the help of PagedList, How Can I do so?
If I am not able to make use of this sql query then what is the way to convert this query in entity framework?
Any help will be useful to me.