DapperLib/Dapper.Contrib

SqlException on hidden parent property

Opened this issue · 2 comments

When using the new modifier on a property within a child class both the property from the parent and child class are added to the SQL parameters causing an exception to be thrown as parameter names must be unique.

For example:

    public class MyParentClass
    {
        [Key] int Id { get; set; }
        public int Value { get; set; }
    }

    [Table("MyChildTable")]
    public class MyChildClass : MyParentClass
    {
        public new string Value { get; set; }
    }

    public class DapperStuff
    {
        private readonly IDbConnection db;
        public DapperStuff(IDbConnection db)
        {
            this.db = db;
        }
        public void DoInsert(MyChildClass insert)
        {
            this.db.Insert<MyChildClass>(insert); 
            // SqlException: The variable name '@Value' has already been declared. Variable names must be unique within a query batch or stored procedure.
        }
    }

Following as I need this too

Same here