Ignoring properties in Dapper

dapper

Solution

Well, Dapper has no `Insert` extension method, that is in dapper.contrib, dapper extensions or dapper rainbow.

Dapper itself allows you to do:

Animal a = new Animal {Age = 10, Family = "Canine"}
// only insert Age
cnn.Execute("insert Animal(Age) values (@Age)", a); 

To work around for some of the extension classes you can sometimes do:

cnn.InsertExtension("Animal", new{a.Age});

Regardless, you can always fall back to raw Dapper for your complex filtered inserts.

Problem

In Dapper, is there a way to ignore properties in the model class, namely when using the `Insert` extension method? My model class has a set of computed properties which are not persisted in the associated table.

Original source