Hi
Error - Cannot implicitly convert type system.linq.Iqueryable to system.collection.generic.list
C#
public List GetStudentCurrent(Int32 StudentId)
{
List Result = (from t in context.StudentDetails
join t2 in context.Student
on t.LoginCode equals t2.StudentID
orderby t.StudentID,t.CreatedOn
select t).Take(1);
return Result;
}Thanks

Rajanikant HawaldarRank #110 · 20.2K reputationPosted Oct 10, 2022, 2:57 AM EDT
public List GetStudentCurrent(Int32 StudentId) { List Result = (from t in context.StudentDetails join t2 in context.Student on t.LoginCode equals t2.StudentID orderby t.StudentID,t.CreatedOn select t).Take(1).ToList(); return Result; }Amit MohantyRank #112 · 20K reputationPosted Oct 10, 2022, 3:02 AM EDT
To convert
IQuerableorIEnumerableto a list, you have to add .ToList() in your query.