Forum Discussion

Alex_is_programming's avatar
Alex_is_programming
Copper Contributor
Oct 03, 2024

EF Core display up to date data on predefine delay

Hi,

I have a C#/WPF project for which I use EF Core (database first) to transact with an SQL database. I am struggling with retreiving fresh data from the server on a predefine delay to be displayed on a dashboard.

 

Scenario is this:

I have an entity call Cars.

Cars has a property that is a virtual ICollection of ToDo call lstToDo

Each ToDo entity has a boolean property call Completed.

The data of SQL database can be modified by many users.

The dashboard is the application running on a computer that no one is using, and that need to display the latest data from the database every X minutes.

 

So in my scenario everything is working fine except that whenever the property Completed is change, in the database, from false to true (or vice-versa) I am unable to get the new value. I tried using Eager Loading but without any luck.It will catch when a new row has been added to the table, but not when a change happen in an existing row.

The eager loading I use:

 

myContext.Cars
  .Include(c => c.lstToDo)
  .Load();

myCollectionViewSource.Source = myContext.Cars.Local.ToObservableCollection();

 

Also, in my context I configured it to use LazyLoading.

 

Any suggestion will be more then welcome

No RepliesBe the first to reply

Resources