Dear Support,
The attached grid application is used by multiple users. The problem is that the Grid does not show fresh data from database. e.g. when user A edit a record, user B does see the changes. it has to Refresh the browser.
1) Can you provide a working modification on the attached grid sample in order to solve the problem?
2)on public async Task Submit() is it possible to refactor the above code in order Not to load the huge amount of records from the database ?
BeneficiaryObjects = await beneficiaryService.GetAllDataAsync(); //VERY LONG RUNNING TASK LOADING HUGE AMOUNT OF RECORDS!
thanks
Hello,
1.can the observable collection help to some extend, as described in your article?
if yes, can you please provide a modified working sample of the attached project with observable collection ?
2.can you also provide a modified working sample of the attached project blazor datagrid & signalr which you suggested?
thank you
hello,
you can use update-database in packagemanager console to create the database "ef code first"
the connection settings are inside appsettings.json
and database server is : (localdb)\\mssqllocaldb
i attach the database for your own reference. (it is just on table).
awaiting the signal r example .thank you
Hello,
"delete" and new "adding data" is reflected to user B and working ok.
" Updating/editing" data is not reflected on user B and not working.
it is even not working when changing a page and going back . can you please recheck ?
thank you
Dear Vignesh,
1.the sample you provided above is not compiling.
2.regarding the very simple sample we attached ,I don't see any problem with the UpdateBeneficiary & GetAllDataAsync Code in BeneficiaryService.
do you see anything that it must be changed in order to make it work ?
===see code below===
public async Task<Beneficiary> UpdateBeneficiaryAsync(Beneficiary model)
{
var data = await db.Beneficiaries.Where(m => m.Id == model.Id).FirstOrDefaultAsync();
if (data != null)
{
data.Id = model.Id;
data.FirstName = model.FirstName.Trim();
data.LastName = model.LastName.Trim();
data.DocId = model.DocId;
await db.SaveChangesAsync();
}
return data;
}
public async Task<List<Beneficiary>> GetAllDataAsync()
{
var result = await db.Beneficiaries.ToListAsync();
return result;
}
|
protected override async Task OnInitializedAsync()
{
hubConnection = new HubConnectionBuilder()
.WithUrl(NavigationManager.ToAbsoluteUri("/chathub"))
.Build();
hubConnection.On("ReceiveMessage", () =>
{
CallLoadData();
StateHasChanged();
});
await hubConnection.StartAsync();
BeneficiaryObjects = await beneficiaryService.GetAllDataAsync();
StateHasChanged();
}
private void CallLoadData()
{
Task.Run(async () =>
{
await LoadData();
});
}
protected async Task LoadData()
{
BeneficiaryObjects = await beneficiaryService.GetAllDataAsync();
await Task.Yield();
await InvokeAsync(StateHasChanged);
GridnameBeneficiary.Refresh();
}
|
Hi DAN,
Not sure if you found the problem. If you EF Core, put your query in its own "using" the statement, for example:
using (var context = new APPContext())
{
return await context.Beneficiary.ToListAsync();
}
Hi DAN,
Thanks for the update.
We are currently checking the reported query from our end and we will update the further details within two business days. Until then we appreciate your patience.
Regards,
Rahul
Hi Fouche Burgers,
Thanks for the update.
Please get back to us if you have any queries.
Regards,
Vignesh Natarajan