Query() Result holds old data

Hello,

I'm not sure if I miss something but on open a dialog from a grid we use a Query to select the current data from Database to have the result present of Triggers (SQLServer DB) in our dialog.

the problem is that the SQL is executet on the database but the values of the query are the old ones - what I'm missing?
is there a cache?
how to force the dialog to show current data from the DB?

var result = await PDBService.GetPfuscherakts(new Query()
{
    Expand = "PfuscherbeziehungAkts, PfuscherbeziehungAkts.Pfuscher, Pfuscherakterhebungs",
    Filter = $@"i => i.Akt_ID == @0",
    FilterParameters = new object[] { Akt_ID }            
});

pfuscherakt = result.FirstOrDefault();

Robert

Yes, there is a EF cache that can be avoided like this:

Ok but if I use

pfuscherakt = result.AsNoTracking().FirstOrDefault();

I get an error on Reload():

System.InvalidOperationException: "The instance of entity type 'Pfuscherakt' cannot be tracked because another instance with the same key value for {'Akt_ID'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values."

                var pdbUpdatePfuscheraktResult = await PDBService.UpdatePfuscherakt(Convert.ChangeType(Akt_ID, Type.GetTypeCode(typeof(int))), pfuscherakt);
                **PDBContext.Entry(pfuscherakt).Reload();**

robert

It depends what you want to do - for CRUD for sure you should use tracking. More info can be found here: