I cannot find any examples of binding a parent and child grid where the datasource is entity objects. I need the two grids to be in sync - when parent record is selected in parent grid, child records should display in child grid. Here is my attempt:
Employees = parent entity
EmployeeForms = child entity
var results = from ncrecord in admincontext.Employees.Include("EmployeeForms")
where ncrecord.EmployeeForms.Any(p => p.DueDate < DateTime.Now)
select ncrecord;
results.Load();
grdParent.DataSource = bindingSourceEmployees;
grdChild.DataSource = bindingSourceForms;
bindingSourceEmployees.DataSource = dbcontext.Employees.Local.ToBindingList(); // have also tried just dbcontext
bindingSourceEmployees.DataMember = ??; // "Employees" does not work - DataMember property 'Employees' cannot be found on the DataSource.
bindingSourceForms.DataSource = bindingSourceEmployees;
bindingSourceForms.DataMember = ??; // have tried name of relation
I can't use the entity name for datamember, or the data relationship. Both cause errors.