Table of Contents

Class ConcurrencyErrorsException

Namespace
Breeze.Persistence
Assembly
Breeze.Persistence.dll

Thrown when a save fails because a row was changed or removed by someone else after it was read - an optimistic concurrency conflict.

public class ConcurrencyErrorsException : EntityErrorsException, ISerializable
Inheritance
ConcurrencyErrorsException
Implements
Inherited Members

Remarks

A persistence manager raises this in place of whatever its ORM throws, so that a conflict reaches the client the same way whatever is underneath: EF Core's DbUpdateConcurrencyException and NHibernate's StaleObjectStateException both arrive as 409 Conflict with ProblemTypeUri as the RFC 9457 type.

409 alone is not enough to act on, because a duplicate key is also 409 and the recovery is different - re-read and merge here, change the data there. The type member is what separates them, and it is stable in a way that an ORM's message text is not.

Being an EntityErrorsException, it also carries one EntityError per conflicting row, each naming the entity type and key values. A breeze client turns those into validation errors on exactly the entities that conflicted, which is what lets an application show the user which records to look at rather than failing the whole save with one message.

Constructors

ConcurrencyErrorsException(string, IEnumerable<EntityError>)

Create from the entities that conflicted.

public ConcurrencyErrorsException(string message, IEnumerable<EntityError> entityErrors)

Parameters

message string

Explanation for the save as a whole; becomes the problem document's detail.

entityErrors IEnumerable<EntityError>

One error per conflicting entity. May be empty if the ORM does not say which rows failed.

Fields

DefaultEntityMessage

The default ErrorMessage for a conflicting entity.

public const string DefaultEntityMessage = "This record was changed or deleted by another user after it was read."

Field Value

string

ErrorName

The ErrorName on each conflicting entity.

public const string ErrorName = "ConcurrencyError"

Field Value

string

ProblemTypeUri

The RFC 9457 problem type for an optimistic concurrency conflict.

public const string ProblemTypeUri = "https://breeze.github.io/problems/concurrency-conflict"

Field Value

string

Methods

CreateEntityError(string?, object[]?, string?)

Build the EntityError for one conflicting entity.

public static EntityError CreateEntityError(string? entityTypeName, object[]? keyValues, string? errorMessage = null)

Parameters

entityTypeName string

The entity type's full .NET name, as Namespace.Type. A breeze client normalizes it.

keyValues object[]

The entity's key values, in key order, so the client can find the entity it already holds. May be null if unknown.

errorMessage string

Message for this entity; defaults to DefaultEntityMessage.

Returns

EntityError

An EntityError with ErrorName and no property name, so the client attaches it to the entity rather than to one of its properties.

CreateMessage(int)

The message for the save as a whole, given the number of rows that conflicted.

public static string CreateMessage(int count)

Parameters

count int

How many entities conflicted; 0 if the ORM did not say.

Returns

string

A message suitable for the problem document's detail.