Last post Nov 04, 2020 12:26 PM by yogyogi
Oct 19, 2020 10:35 AM|cicciuzzo|LINK
I need to load all my related entity with updated data but when a call my method this does not happen.
My application load al data only if I restart it.
This my code
private readonly ScaDbContext scaDbContext;
public WBadgeCompany(ScaDbContext scaDbContext)
this.scaDbContext = scaDbContext;
private List<AssignCompany> GetAssignCompanies()
List<AssignCompany> assignCompany = new List<AssignCompany>();
assignCompany = scaDbContext.assignCompanies.Include(a => a.Badge)
.Include(a => a.CompanyContact).ThenInclude(c => c.Company)
.Include(a => a.UserStart)
.Include(a => a.UserEnd).DefaultIfEmpty()
.OrderBy(a => a.DataEnd)
Oct 20, 2020 08:54 AM|yij sun|LINK
Accroding to your description,could you tell us what's your dependency injection?And how your call the method which load the dbcontext data?
I'm guessing that you have used a Singleton class which led to this problem.It will load the data and don't update.
You could post more details of your codes to us.It will help us to solve your problems.
Nov 04, 2020 12:26 PM|yogyogi|LINK
Check the Startup.cs class to find out if you are registering the Database context file like this:
public void ConfigureServices(IServiceCollection services)
Refer this tutorial to find out more on registering database context.
If this is not the case then probably you are using Singleton patter which is causing this thing. You can post your full code of the Startup.cs class so that we can check.