'Showing newest data with Entity Framework on WPF
I'm using WPF with Entity Framework and SQL, but i have a problem. Start, i'm created new data with status = false on desktop app. Next, i'm updated data on another device ( change status "false" => "true" ), and now i'm comeback to desktop app and query data with condition status = "true", load the data and binding on listview success, but on the column status data, it showing "false",it is show the right data is "true" when im restart the app. So, how can i show the newest data on Views immediately
I don't know how can it load the data with condition "true" but showing data is "false"
private void LoadData()
{
ListInventory = new ObservableCollection<Models.Inventory>(DataProvider.Ins.DB.Inventory
.Where(x => x.StatusInventory == true)
.Include(x => x.InventoryDetail));
}
Sorry for my bad english.
UPDATE: I'm reload Dbcontext and it worked properly but i don't think it's the solution
var entity = DataProvider.Ins.DB.ChangeTracker.Entries().ToArray();
foreach (var item in entity)
{
item.Reload();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
