Hi
Please Help
I am using LINQ Self Join Query to display data on the view .my sql query contains some employees details .i need to show employee details with their Manager Name .
but when i use my var type of resultant list of i get runtime exception
my code is in controller action
var emp = from m in t.Employees
join e1 in t.Employees on m.ManagerID equals e1.EmployeeID
select new { Id = m.EmployeeID , Name = m.Name, Manager = e1.Name , Designation = m.Designation,Phone =m.Phone ,address = m.Address };
return View(emp);
and in view
@model IEnumerable <mvc4application.models.employee>
and getting error
The model item passed into the dictionary is of type System.Data.Objects.ObjectQuery`1[<>f__AnonymousType1`6[System.Int32,System.String,
System.String,System.String,System.Nullable`1[System.Int32],System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Mvc4application.Models.Employee]'.]
System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +405487
Off Course i am understanding this because my view is using Mvc4application.Models.Employee type .
any solution is appreciated .as i am not able to convert it to model type .