I am trying to update with Dapper.Contrib this table:
public class MyTable
{
public int ID { get; set; }
public int SomeColumn1 { get; set; }
public int SomeColumn2 { get; set; }
public int CreateUserID { get; set; }
public int UpdateUserID { get; set; }
}
I don't want to update the CreateUserID column because it is an update method so that I want to ignore this column while calling the Dapper - Update.Async(entity) method.
I tried using [NotMapped] and [UpdateIgnore] attributes but no help.
Note: I still want this column to be passed on insert operations, therefore, [Computed] and [Write(false)] is not appropriate.
Can someone help me figure out how to ignore this column when updating the table in the database?
As @Evk already mentioned in his answer, there is no solution implemented yet. He have also mentioned the workarounds.
Apart from that, you can choose to use Dapper (IDbConnection.Execute(...)
) directly bypassing Dapper.Contrib for this particular case.
I had a similar problem (with DapperExtensions though) with particular column update and other complex queries those DapperExtensions either cannot generate at all or need much work to make it happen with it.
I used Dapper directly instead of DapperExtensions for that particular case; other part of project still take benefit of DapperExtensions. This is like tread-off. Such cases are very limited. I found this is better solution instead of tweaking/forcing DapperExtensions for this. This also saved me on time and efforts.