Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No optimistic concurrency check, when having a RowVersion column and executing the BulkUpdate() method #34

Open
AntonZhmyrov opened this issue May 17, 2021 · 2 comments

Comments

@AntonZhmyrov
Copy link

Hello!

Thank you for a great and fast library!

Unfortunately, I have run into an issue, when using the BulkUpdate() method, it does not enforce the optimistic concurrency check.
When having the 'RowVersion' column, and in concurrent scenarios, BulkUpdate() just overwrites the changes, ignoring the fact that the same version of data was already modified by different source.

Could you help with that please?

@mtanneryd
Copy link
Owner

mtanneryd commented May 17, 2021 via email

@AntonZhmyrov
Copy link
Author

Sure, it is fairly easy to reproduce. Here is some pseudocode:

public class Item
{
    public long Id { get; set; }

    public string Name { get; set; }

    public byte[] RowVersion { get; set; }
}

// query for item with rowversion using EF 6
var item = await _dbContext.Items.FirstOrDefaultAsync();

// update name
item.Name = "New Name";

// save the updated entity
_dbContext.SaveChangesAsync();

var updateRequest = new BulkUpdateRequest
{
     Entities = new List<Item> { item } as IList,
     UpdatedColumnNames = new[]
     {
         nameof(Item.Name);
     }
};

// do bulk update on already updated entity, row version is different for it in DB, but no exception thrown, and changes are //overwritten
_dbContext.BulkUpdateAll(updateRequest);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants