Dapper is able to map this query to the car
object. It knows which property in the car goes to which variable in the query.
Car car = new Car();
conn.Execute(
"UPDATE CAR" +
" SET COLOR=@Color,MODEL=@Model" +
" WHERE ID=@Id", car;
But can I add another variable to the query? E.g:
int c = 1000;
conn.Execute(
"UPDATE CAR" +
" SET COLOR=@Color,MODEL=@Model,COST=@cost" +
" WHERE ID=@Id", car, new { cost = c };
I'd like to do this without having to match every property in the car object to a variable in the query. Here's the example class, but I have a lot more properties in my real class.
public class Car {
public int Id { get; set; }
public string Color { get; set; }
public string Model { get; set; }
}