I have a data bound list box that was built using the EF 4.1 model first. So all my classes where built for me. Because I have three controls that reflect the table data that traces back from the foreign key. this.lstBox2.ItemSource = entityContext.TableObject2.ToList() will return every record. Not the records that the M-D are showing limited by the foreign key constraint.
TableObject2 class2 = new TableObject2();
class2.value1 = 0;
class2.value2 = "new location";
using (TKOEntities entityContext = new TKOEntities())
{
entityContext.TableObject2.AddObject(class2);
entityContext.SaveChanges();
this.lstBox2.ItemsSource = null;
}
SaveChanges does update the data into the database. But the control is not refreshed (this.lstBox2.Refresh() doesn't work). If I try to set the value to the control. I also get the us ItemControl.ItemSource error. How do I assign the control the updated values saved to the entitycontext?