Skip to content

Dapper.Contrib Update Fails #398

@adamfisher

Description

@adamfisher

After trying version 1.40 and 1.42, I am still unable to do update a database table using the Dapper.Contrib Update extension method.

My method acquires an IDbConnection successfully but when it tries to do the update, it complains Incorrect syntax near the keyword 'User'. I am able to successfully use this update syntax with my other models and there doesn't appear to be anything glaringly different. I also tried querying for a record successfully and then passing it back to update presents the same issue. I suspect maybe something weird with data types? Grasping at straw at this point.

public int Update(User model)
{
    using (var db = ConnectionFactory.Current.CreateConnection(new DbContext()))
    {
        return db.Update(model) ? 1 : 0;
    }
}

Here is my model:

[Table("User")]
    public class User
    {
        [Key]
        public long UserId { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string UserIdType { get; set; }
        public string UserIdValue { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Address1 { get; set; }
        public string Address2 { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string ZipCode { get; set; }
        public DateTime? DateOfBirth { get; set; }
        public string EmailAddress { get; set; }
        public string PhoneNumber { get; set; }
        public int? ApplicationId { get; set; }
        public DateTime CreatedOn { get; set; }
        public DateTime? ModifiedOn { get; set; }
        public int? CredentialType { get; set; }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions