Is there a way to ignore property from being mapped in runtime. Because I don't know if database has specific column and I have to check it before doing insert. If database doesn't have column then I want to ignore this one specific property.
UPDATE:
Here's my insert code
public static void Insert(string connectionString, T entity)
{
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
connection.Insert(entity);
}
}
That
Insert
method is part of Dapper.Contrib, not Dapper itself. As the Readme for that library explains, you can use the[Write(false)]
attribute to specify that a property isn't writeable, eg :The source code shows that Dapper.Contrib simply ignores properties that aren't writable :
Dapper is a microORM, it doesn't offer the mapping features found in full ORMs like EF or NHibernate. Dapper.Contrib adds some helper methods and very basic mapping through 5 atrributes:
[Table("Tablename")]
to specify the table name[Key]
to mark an auto-generated key field[ExplicitKey]
to mark a field that isn't generated automatically[Write(true/false)]
to mark (non)writable properties[Computed]
to mark calculated properties.There's no way to specify a column name for example