I try to update a data grid every minute with new data from database, How can I update the data in the EF context? Database is a MySql Database.
You need to execute the code which populates the property that the DataGrid is bound to.
<RadzenGrid Data=@products />
<RadzenButton Text="Refresh" Click=@Refresh />
@code {
IEnumerable<Product> products;
void Refresh()
{
products = myDbService.GetProducts();
}
}
This is the same as generated in the Load() methode:
protected async System.Threading.Tasks.Task Load()
{
var moTeCa66DbGetScenariosResult = await MoTeCa66Db.GetScenarios();
getScenariosResult = moTeCa66DbGetScenariosResult;
var moTeCa66DbGetUsersResult = await MoTeCa66Db.GetUsers();
getUsersResult = moTeCa66DbGetUsersResult;
scenarioqueue = new MoTeCa66Gui.Models.MoTeCa66Db.ScenarioQueue(){};
var moTeCa66DbGetScenarioQueuesResult = await MoTeCa66Db.GetScenarioQueues();
getScenarioQueuesResult = moTeCa66DbGetScenarioQueuesResult;
}
<RadzenGrid @ref="grid0" AllowFiltering="true" AllowPaging="true" AllowSorting="true" Data="@getScenarioQueuesResult" TItem="MoTeCa66Gui.Models.MoTeCa66Db.ScenarioQueue" RowUpdate="@Grid0RowUpdate">
If I call the Load() from button, I see the select statement in vs, but nothing is change in the grid.
@Prefekt I think you can get some useful info from the last few messages on my thread here https://forum.radzen.com/t/updating-a-stored-procedure-parameter/5067/4
where I had similar questions. I was referring to a Stored Procedure, but it doesn't make any difference. Invoke the data source method, and set ${result} to it (again). Note that this will re-query the database, which you usually do not want to do. Generally you'd want to use "await componentname.Reload()" to update the component instead of invoking the table again.
Stephen
I wonder, if I execute Load(), I see this in the output window:
dotnet: info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (12ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*)
FROM `scenario_queue` AS `s`
dotnet: info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (12ms) [Parameters=[@__p_1='?' (DbType = Int32), @__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30']
SELECT `t`.`id`, `t`.`scenarioid`, `t`.`scenariostatus`, `t`.`timestamp`, `t`.`userid`, `s0`.`id`, `s0`.`description`, `s0`.`timestamp`, `u`.`id`, `u`.`active`, `u`.`comment`, `u`.`email`, `u`.`password`, `u`.`roleid`, `u`.`timestamp`, `u`.`username`
FROM (
SELECT `s`.`id`, `s`.`scenarioid`, `s`.`scenariostatus`, `s`.`timestamp`, `s`.`userid`
FROM `scenario_queue` AS `s`
ORDER BY (SELECT 1)
LIMIT @__p_1 OFFSET @__p_0
) AS `t`
LEFT JOIN `scenario` AS `s0` ON `t`.`scenarioid` = `s0`.`id`
LEFT JOIN `user` AS `u` ON `t`.`userid` = `u`.`id`
But the data in the datagrid does not change.
@SloSuenos: Thank you for the hints, I will try