Optimistic Concurrency with timestamp field in SQLServer Issue

I have a table with a timestamp field for concurrency.

I opened 2 browsers of the app generated via Radzen CRUD. I bring up the same record in each browser to update using the Edit CRUD page. After updating some data with 1 browser session I try to update the record in the second session. An error is displayed as expected showing that concurrency is working. However when I click cancel and return to the DataGrid, the update shows on the grid. Noted, that the data did not in fact update the database, however, the datagrid is incorrectly updated.

Additionally noted that in the 2nd session, I'm not able to edit any of the records in the datagrid unless a refresh the page

Hey @kirank,

Optimistic concurrency is available for Blazor WebAssembly applications only while your post is for Blazor server-side. There should be Reload() button when concurrency error is shown exactly to refresh the local data and to get the latest from the server.

Thank you.

Is Optimistic Concurrency likely to be released for Blazor Server Apps? Optimistic Concurrency is also important for Server Apps.

We don’t have plans for such feature for server-side Blazor. Frankly, I’m not sure if it’s even possible.

It seems the issue is wider than I thought.

I tried the following. I have 2 tables (Products, Customers) for which I generated CRUD with Concurrency ticked. Each have a timestamp data type. I opened 2 browsers (one in Edge and 1 in Chrome) with both displaying Products. I edit a product (say Product ID: 1) in Edge and save changes. I edit Product ID: 2 in Chrome. No issues. I then edit Product ID: 1 in Chrome but get an error presumably before Product ID 1 was also edited in the first browser. That is fine.

But the issue now is I can't edit any Products in Chrome. I keep getting an error. I can't even now edit any Customers either as error displayed for Customers too. The only fix seems to be is to reload the application in Chrome.

Sorry that should be Concurrency not ticked.

I have a concurrency issue on my server side app. I can edit a record once then if I open it to edit again without making any changes I get a concurrency error. After searching i found that my issue relates to the entity framework entity state.

My solution is to add the app. Reset() after the save routine. It’s cured the problem at least as far as I can tell.

When you look at the Radzen app.Reset() routine it’s resetting the context state which avoids having to refresh the page sorts and out the problem. As yet I haven’t found a downside.

It may or may not give you a clue as to how to solve your issue.

Hope this helps.

John

Thanks John. Appreciate your reply. I'll take a look at it.

I did a search and came across this: https://gist.github.com/SteveSandersonMS/9451f3b5497ce2b5ad16b0d07ad73539

It talks about Blazor Server Apps treating most unhandled exceptions as fatal to the circuit. It's probably why when I get an error on CRUD with one table, other tables also have errors when editing records.

Maybe there is an unhandled error in the Radzen generated code. Hopefully someone at Radzen will take a look.