You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an entity in which I want to control concurrency. For that, in the database i have a version field but the entity doesn't need this property for doing its work, so I was thinking if there is some way to configure entity core to control concurrency.
I was thinking to use a shadow property, in this way:
But I would like to know if there is some way to configure Entity Core to update version.
I have seen that HasValueGenerator generates a value when SaveChages() is called, but if I am not wrong, it works only when the entity is added to the context to be added, it doesn't work to update the value of a property of an existing entity.
In this way, I could handle concurrency in only once place, in the repository. Because if not, I would need to add a property to my domain entity and increase the value in the domain each time I modify the root entity or I handle some of its children. But I also I have to configure Entity Core to handle concurrency setting the version property. So I have this in two places.
If Entity Core would allow to increase the version property, I could avoid to have a version property in the domain, that it is not really its responsability, and I avoid too to have to configure the concurrency in two places, the domain and the repository.
It is true that in this case the version will be increased each time i call the SaveChages(), but in my case it is not a problem, because I have a repository only for commands, and I istantiate a repository each time I perform an action, so the entities that there is in the repository I will be needed to increase the version.
So in sumary, is it possible to configure the shadow property to be a concurrency token and increase its value each time I call the SaveChanges()?
Thanks.
The text was updated successfully, but these errors were encountered:
Hello:
I have an entity in which I want to control concurrency. For that, in the database i have a version field but the entity doesn't need this property for doing its work, so I was thinking if there is some way to configure entity core to control concurrency.
I was thinking to use a shadow property, in this way:
But I would like to know if there is some way to configure Entity Core to update version.
I have seen that HasValueGenerator generates a value when SaveChages() is called, but if I am not wrong, it works only when the entity is added to the context to be added, it doesn't work to update the value of a property of an existing entity.
So perhaps I was thinking something like this:
In this way, I could handle concurrency in only once place, in the repository. Because if not, I would need to add a property to my domain entity and increase the value in the domain each time I modify the root entity or I handle some of its children. But I also I have to configure Entity Core to handle concurrency setting the version property. So I have this in two places.
If Entity Core would allow to increase the version property, I could avoid to have a version property in the domain, that it is not really its responsability, and I avoid too to have to configure the concurrency in two places, the domain and the repository.
It is true that in this case the version will be increased each time i call the SaveChages(), but in my case it is not a problem, because I have a repository only for commands, and I istantiate a repository each time I perform an action, so the entities that there is in the repository I will be needed to increase the version.
So in sumary, is it possible to configure the shadow property to be a concurrency token and increase its value each time I call the SaveChanges()?
Thanks.
The text was updated successfully, but these errors were encountered: