I have a Blazor page where I could edit a child record in a structure like
Mastertable (one -> many) child table (one -> many) childchild table.
Every table are connected to some lookuptables/data.
My editpage for Mastertable work fine and also my editpage for childchild table.
On my headpage I could choose to list all Masterrecords, I have a list where I could list all records in child table and so on. Here I could without any error click on my link that take me to /editchild/{id}
But if I'm at mastertable edit page and list childrecords, i could click on my link that take me to /editchild/{id}. But than it crash on my rows where I load my lookuptabledata in async Task OnInitializedAsync().
lookupTableAList = await ARepository.GetAllAsync();
lookupTableBList = await BRepository.GetAllAsync();
lookupTableCList = await CRepository.GetAllAsync();
lookupTableDList = await DRepository.GetAllAsync();
masterTableList = await MasterRepository.GetAllAsync(); // Get all records in mastertable so I can link to another masterRecord with a dropdown
Anyone who has a clue why it works if I came from my headpage without any records loaded but if I call my childedit page from a page where my masterdata is loaded, it crash?
Repository for lookuptables like (get from a generic repository):
public virtual async Task<List<T>> GetAllAsync()
{
return await _db.Set<T>().ToListAsync();
}
MasterRepository like :
public async Task<IEnumerable<MasterEntity>> GetAllAsync()
{
IEnumerable<MasterEntity> masterEntity = await _db.MasterEntity
.Where(u => !u.IsDeleted)
.OrderBy(o => o.Name)
.ToListAsync();
return masterEntity;
}
Latencyproblems, conflict from one page to another in Blazor, generic repository problems or something else?
EDIT : If I place await Task.Delay(1000); between every Repository.GetAllAsync(); it won't crash when I call this editpage from edit masterrecord page. But that's not a nice solution.
I think I'm found my problems but not a solution. In my Masteredit page the childtable using Radzen Grid as a master-child connection with selection turned on. So when I click on my link, at the same time it activate a selectrow call that make a call to repository on Masteredit page, so I got an threadconflict to my dbcontext.
Is there a way to get my loaded childpage to wait for thread on masterpage to be finished?