I am working on a ASP.net MVC project and want to display a particular users data which i get as a id through session. According to that id I want to extract all data of particular employee. for that I did this code:
My controller's Index method:
public ActionResult Index()
{
object s = Session["EmployeeID"];
var sessval = s.ToString();
AdminDetailsModel model = new AdminDetailsModel();
var data1 = (from e in db.Employees.Where(c => c.EmployeeID == sessval) join d in db.Designations on e.Designation1up equals d.Designation1up select new { EmployeeID = e.EmployeeID, FirstName = e.FirstName, LastName = e.LastName, DesignationInternal = d.DesignationInternal, DesignationExternal = d.DesignationExternal, OfficePhone = e.OfficePhone, CellPhone = e.CellPhone, JoiningDate = e.JoiningDate, EmailID = e.EmailID, Address = e.Address }).SingleOrDefault();
return View(data1);
}
I have created viewmodel for this in which i took all the methods which I need to display in view.
I have created view on this method which is strongly typed on my model class. when I run it, I got error as:
System.InvalidOperationException: The model item passed into the dictionary is of type '<>f__AnonymousType1`10[System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.DateTime,System.String,System.String]', but this dictionary requires a model item of type 'ResourceTracking.Employee'.
what should I do now?