1.Your view is waiting for a Model of type "list" of
Employee
and you are sending to it a "list" of
Anonymous
type created by your LINQ selection.
2.The solution is to create a new class named
EmployeeModel
class that will have only those properties that are needed into your view; then you should change your view to be a "list" of this
EmployeeModel
. This class can be used directly in your LINQ expression above to create the model for your view like below:
public class EmployeeModel
{
public int ID{get;set;}
public string Description{get;set;}
public int Group{ get; set;}
public double Price{get;set;}
}
public ActionResult Index()
{
var ivtfval = (from a in dbcontext.Employees
select new EmployeeModel { ID= a.id, Desciprion = a.descript, Group =a.grp, Price = a.price }).Take(16);
return View(ivtfval.ToList());
}