i have created the folloiwng view model class
public class viewmodelclass
{
public IEnumerable<Question> Questions { get; set; }
public decimal Total { get; set; }
public string Message { get; set; }
}
then i wrote the following method to create viewmodelclassobjects in my repository model class:-
public IQueryable<viewmodelclass> d (int number)
{ var q_t = new viewmodelclass()
{
Message = "This question current;y have" + number,
Total = number,
Questions = from question123 in entities1.Questions
where question123.QuestionID >= number
select question123
};
return q_t;}
which will be called using the following method inside my controller class:-
public ActionResult dd (int number = 0)
{ var q2 = elearningrepository.d(number);
return View(q2);}
but i am receiving the following error on *return q_t*:-
Cannot implicitly convert type ‘Esystem.ViewModels.viewmodelclass’ to ‘System.Linq.IQueryable’. An explicit conversion exists (are you missing a cast?)
so how i can overcome this error ?
BR
Modify the “d” method to return just the viewmodelclass
Modify your view to expect a viewmodelclass as its model.
you really don’t have to pass an IQueryable in this instance.