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

Error calling AsyncUpdate against SQL Server database with identity primary keys #56

Open
MoxiePoxy opened this issue Jan 28, 2019 · 0 comments

Comments

@MoxiePoxy
Copy link

MoxiePoxy commented Jan 28, 2019

The UpdateAsync method in version 2.0.1 attempts to write primary key values on update. This causes an exception on SQL Server where the primary keys are identities.

This fix is in the main branch of PetaPoco’s Database class in the ExecuteUpdate method:

// Don't update the primary key, but grab the value if we don't have it
if (string.Compare(i.Key, primaryKeyName, true) == 0)
{
    if (primaryKeyValue == null)
        primaryKeyValue = i.Value.GetValue(poco);

        continue;
}

if (primaryKeyValue == null && primaryKeyValuePairs.ContainsKey(i.Key)) {

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

1 participant