Can some one please give a example of how to bind result to a datagridview which taken from multiple tables (from a join query) in entity framework. actually i can bind data to the datagridview but when i call
context.SaveChanges(); nothing has updated in the database. How to correctly bind data to datagridview with Update,Insert,Delete functions.
This is what i tried.
public class DataBindingProjection
{
public string dono { get; set; }
public int apmntid { get; set; }
public string servicedesc { get; set; }
public string cusid { get; set; }
public string empid { get; set;
public bool isdelivered { get; set; }
}
context = new HHCSEntities();
var query = from d in context.DeliveryOrders
join a in context.Appointments on d.ApmntId equals a.ApmntId
join s in context.ServiceCategories on d.ServiceId equals s.ServiceId
join e in context.Employees on d.EmpId equals e.EmpId
select new DataBindingProjection
{
dono = d.DONo,
apmntid = a.ApmntId,
servicedesc = s.ServiceDesc,
cusid = a.CusId,
empid = d.EmpId,
shortname = e.ShrtName,
isdelivered = d.IsDelivered
};
dataGridView1.DataSource = query.ToList();
dataGridView1.Columns[1].DataPropertyName = "dono";
dataGridView1.Columns[2].DataPropertyName = "apmntid";
dataGridView1.Columns[3].DataPropertyName = "servicedesc";
dataGridView1.Columns[4].DataPropertyName = "apmntid";
dataGridView1.Columns[5].DataPropertyName = "empid";
dataGridView1.Columns[9].DataPropertyName = "isdelivered";
Thanks in advance.