I have the following
Engineer Model:
public class engineers { public Guid? Guid { get; set; } public string Name { get; set; } }
I fill out a list of engineers with the right details:
List<engineers> listeng = new List<engineers>(); listeng.Add(new engineers { Name = profile.FirstName + " " + profile.LastName, Guid = GuidEngineer });
So far so good.
My question is: how can I pull the engineer name onto the eng entry below:
var tickets = from o in new HelpdeskEntities().Tickets.Where(t => t.TicketState.State == "Open") select new AjaxTickets { TicketID = o.TicketID, TicketSubject = o.TicketSubject, ClientCompanyName = o.ClientCompany.ClientCompanyName, DateOpened = o.DateOpened, **eng** = list.Where(x => x.Guid == o.EngineerID).Select(x => new engineers {Guid = x.Guid, Name=x.Name }).FirstOrDefault().Name };
I also tried
var tickets = from o in new HelpdeskEntities().Tickets.Where(t => t.TicketState.State == "Open") select new AjaxTickets { TicketID = o.TicketID, TicketSubject = o.TicketSubject, ClientCompanyName = o.ClientCompany.ClientCompanyName, DateOpened = o.DateOpened, **eng** = list.Where(x => x.Guid == o.EngineerID).Select(x => x.Name }).FirstOrDefault() };
The error I am getting is:
Unable to create a constant value of type 'Helpdesk2.ViewModel.engineers'. Only primitive types ('such as Int32, String, and Guid') are supported in this context."}
Which I understand, but I canโt understand, just choose the name of the engineer.
Thanks in advance
source share