I'm using Linq and just started working with it. My gridview was populating when I was using a single table, but now I am trying to join a Client First Name from the Client Info table.
Error is Event_Setup does not contain a definition for ClientFirstName. So it is checking Event_Setup table instead of Client_Info.
public List<EventData> GetDetails()
{
using (EMSEntities db = new EMSEntities())
{
var context = from events in db.Event_Setup
join clients in db.Client_Info on events.ClientId equals clients.ClientId
select events;
List<EventData> newEvent = new List<EventData>();
foreach (var e in context)
{
EventData test = new EventData();
test.Event_Title = e.EventTitle;
//Error on e.ClientFirstName, Event Setup does not contain Definition
(located in Client_Info table not Event Setup)
test.Name = e.ClientFirstName;
test.Start_Date = e.EventDateFrom;
test.End_Date = e.EventDateFrom;
newEvent.Add(test);
}
return newEvent;
}
}
DAL
public class EventData
{
public string Event_Title { get; set; }
public string Name { get; set; }
public DateTime? Start_Date { get; set; }
public DateTime? End_Date { get; set; }
}