Created
August 26, 2016 12:13
-
-
Save timabell/945b2b30e562256571a9192ec9869061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// method to add to dbcontext | |
/// <summary> | |
/// Set EF's OriginalValue of RowVersion for 'entity' to the supplied value. | |
/// This allows you to make use of EF's built-in concurrent-editing | |
/// when you don't have the entity as it was presented to the user to | |
/// edit (because of the stateless nature of the web). | |
/// Call this before SaveChanges to ensure concurrent edits don't go | |
/// unnoticed by users. | |
/// More info: http://stackoverflow.com/a/9190378/10245 | |
/// </summary> | |
/// <typeparam name="TEntity">The type of the entity.</typeparam> | |
/// <param name="entity">The entity for which you want to change the source row version in EF's original value cache.</param> | |
/// <param name="value">The new value for the original row version.</param> | |
public void SetOriginalRowVersion<TEntity>(TEntity entity, byte[] value) where TEntity : class | |
{ | |
Entry(entity).OriginalValues["RowVersion"] = value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment