This my method in my repository:
public List<Question> getallquestion()
{
var hej = from Core in db.CoreValue
join Question in db.Question on Core.CID equals question.QID
join Subject in db.SubjectType on Core.CID equals Subject.SID
select new
{
Core.Cname,
Question.QuestionText,
Subject.Sname
};
return hej.ToList();
}
This is the error:
Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'NKI3.Models.Question'
What is the solution for this error? I cant seem to find it
My CreateViewModel:
public class CreateViewModel
{
public string QuestionText { get; set; }
public string Sname { get; set; }
public string Cname {get;set;}
}
}
Thanks in Advance!
Best Regards!
Change your select to read like so:
In your controller you would do something like this: