Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
778 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
In my Blazor Server application, I am updating OrderDetails as follows.
public async Task UpdateReportAsync(List<OrderDetail> reports)
{
_db.UpdateRange(reports);
await _db.SaveChangesAsync();
}
So far so good, when I check the database I see data is updated. Then I navigate to another page that displays all of the orders and details, but for some reason, it still shows data as not updated.
Here is the OnInitializedAsync:
protected override async Task OnInitializedAsync()
{
user = (await _authenticationStateProvider.GetAuthenticationStateAsync()).User;
if (!user.Identity.IsAuthenticated)
{
NavigationManager.NavigateTo("/Identity/Account/Login", false);
}
_orders = await ViewAllOrdersUseCase.ExecuteAsync(user);
SelectedOrders = new List<Order?> { _orders.FirstOrDefault() };
}
Here is how _orders are populated:
public async Task<IEnumerable<Order?>> GetAllOrders(ClaimsPrincipal user)
{
var result = await _db.Orders
.Include(d => d.OrderDetails.Where(od => od.IsActive == 1))
.ThenInclude(v => v.Vendor)
.Include(c => c.Customer)
.OrderByDescending(s => s.Id)
.ToListAsync();
return result;
}
What can be the problem? Any ideas on how to solve this?
Thank you.