Get<T>()/Update() entity tracking changes and issues
In the description of public static T Get<T>(...) method it's said that
"Entities created from interfaces are tracked/intercepted for changes and used by the Update() extension for optimal performance."
To check it I created an interface
public interface IInvoice
{
string Code { get; set; }
InvoiceDetail Detail { get; set; }
[Key]
int InvoiceID { get; set; }
List<InvoiceItem> Items { get; set; }
InvoiceKind Kind { get; set; }
}
for class Invoice : IInvoice and tried the next code:
using (var connection = ConnectionFactory())
{
connection.Open();
IInvoice invoice = connection.Get<IInvoice>(1);
invoice.Code = "Bla bla bla";
connection.Update(invoice);
}
First I got an exception
"Invalid cast from 'System.Int32 to InvoiceDetail." for which I've already made a pull-request.
After fixing it I got another exception at line 417 in SqlMapper.cs
System.NotSupportedException: 'The member Detail of type Z.Dapper.Examples.API.Dapper.Methods.InvoiceDetail cannot be used as a parameter value'
So, now the question is why does it check all the properties while I changed only one? Isn't it going to update them all?