For a Winforms C# application, I’m looking for the EF equivalent of dataset’s tableAdapter.Fill/tableAdapter.FillByBy.
Because they were reusable to refill a GridView (Windforms), possibly using a different ‘where clause’.
The only way I know to fill/refill the GridView from DB now using EF with different parameters:
this.myBindingSource.DataSource = myNewSelectQueryObject;
the ‘first fill’ with this works fine, but the second one will cause the DataSource et the GirdView to be impossible to edit. (Although the BindingSource the GridView are NOT ‘readonly’.) a,d EF.Refresh() doesn’t seem to update records that could be in the DB but are not present in the ‘EF’.
Thank you for your help.
PS : And here is some progress so far:
Refill(){
this.myDataEntities.Refresh(System.Data.Objects.RefreshMode.StoreWins, this.myDataEntities.myEntity);
this.myBindingSource.DataSource = myNewObjectQuery<...>;
this.myRadGridView.DataSource = this.myBindingSource.DataSource;
}
optionnally with :
this.myRadGridView.MasterTemplate.DataSource = this.myBindingSource.DataSource;
not sure if this is usefull.
The RadGridView is not ‘apparently readonly’ anymore.
But then I want to add a record through my BindingSource:
this.myBindingSource.AddNew();
It does not appear in my RadGridView.
While I still can add a record and save it by clicking on using the ‘Click here to add a new row’ tool from the RadGridView.
So there’s some mismatch between the BindingSource and the grid.
It seems that the solution was to make something like this:
}
The important difference is the “new Bindingsource()”.