3
I’ve been using Dapper for a short time and so I have little experience with it. I wonder if there is any way to detect changes in a specific field.
I need this because in a given table, every time a field is updated, I need to update another field, concatenating with ". JPG".
For example
using Dapper.Contrib.Extensions;
// ...
var remessa = conn.Get<Remessa>(1);
remessa.Campo1 = "5000";
// remessa.Campo2 = remessa.Campo1 + ".jpg";
conn.Update(remessa);
In the above example, I need the commented line referring to Campo2
run automatically, every time I run SqlConnection.Update
(that is, I don’t want to keep repeating this excerpt in my application). There is a way to do this with Dapper?
Shouldn’t this field/property then be "calculated"? Do you really need this "real" field if its value is really always dependent on the value of the other? I believe that in the definition of 'remittance', declare it as
public string Campo2 { get { return Campo1 + ".jpg"; } }
would be enough. It does not even need to exist in the bank.– Diego Rafael Souza