How to filter data using Entity Framework in a way that DataGridView be editable and context track changes?

.net c# datagridview entity-framework winforms

Question

I'm using Entity Framework (EFWinForms) with a C# Windows Form Application to populate data from a table in a SQL Server database:

MyEntityDataModel db = new MyEntityDataModel();
MyEDS = new EntityDataSource();
MyEDS.DbContext = db;
MyDataGridView.DataSource = MyEDS;
MyDataGridView.DataMember = "MyTable";

It runs smoothly. The following code can be used to preserve data when a user edits or adds information:

MyEDS.SaveChanges();

In order for MyDataGridView to stay editable and for any user updates to the filtered data to still be saved back to the database, I need a mechanism to filter this data using an entity data source. It's important to keep in mind that using linq to entity to filter data only populates a snapshot of the data that cannot be changed or updated by the user again.

1
9
2/2/2017 6:39:46 PM

Accepted Answer

ZZZ_tmp
19
10/11/2019 6:48:44 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow