Pergunta

I am new to Breeze and in my first project, I am running into "Unable to update the value of concurrency property before saving" error. So far, I have 'create' and 'read' parts working but can not 'update'. I saw this SO question but I am not sure where to look to solve this problem.

My setup is SQL server (11.0.3128.0) accessing the db through Lightswitch Odata service to Breeze and then Angular.

Where do I start? Is this a SQL server problem, Breeze problem, or my programming bug? I am just doing an em.saveChanges() call with a modified entity when this error shows up. The error is reporting on a field which has not been modified but it might be the first field(?).

EDIT----------------

Because the model is automatically generated by Lightswitch, I don't have an access to the code but here is the metadata for the field (FName) which is throwing the error.

<Property Name="FName" Type="Edm.String" Nullable="false" MaxLength="50" ConcurrencyMode="Fixed" xmlns="http://schemas.microsoft.com/ado/2008/09/edm" />

EDIT 2___________________

Lightswitch automatically sets the concurrency mode to "Fixed" on all fields by default and I don't see a way to change or not set it. The problem is then Lightswitch metadata shows these fields as concurrency property fields even though they are not meant to be.

So unless Breeze code can be changed, I don't see a way to make update or delete work with Lightswitch Odata service.

Foi útil?

Solução

It could be a problem with the model. As the comment in the code says, DataTypes of Boolean, String and Byte should not be defined as a concurrency column.

If the field in question is meant to be a concurrency property, please make sure that it is not one of those data types.

If it was not meant to be a concurrency property, perhaps you can post a code snippet on how you're defining your model.

EDIT:

If, for any reason, that you're unable to change the model, you can bypass Breeze's concurrency check by implementing this hack:

entityManager.metadataStore.getEntityTypes()
 .forEach(function(entityType) { 
     entityType.concurrencyProperties = [];
});

Please note that with this implementation, you are now responsible for having your own concurrency check mechanism, either on the client or on the server.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top