I need help in getting value from my linq query. Using firstordefault()
var item = (from o in db.Employee
join a in db.EmployeeLineManager on o.Id equals a.EmployeeID
where o.Id == Id
select new
{
AddedBy = o.LastName + " " + o.FirstName,
LineManagerId = a.LineManagerId,
Email = o.Email
}).FirstOrDefault();
I can get what is in the item(e.g if I want to get email, I can use item.Email)
But, if I use ToList()
var item = (from o in db.Employee
join a in db.EmployeeLineManager on o.Id equals a.EmployeeID
where o.Id == Id
select new
{
AddedBy = o.LastName + " " + o.FirstName,
LineManagerId = a.LineManagerId,
Email = o.Email
}).ToList();
How do I get value from the item(e.g i want to get the Email, item.Email does not work, please what can I use to get the values?