DapperLib / DapperLib/Dapper.Contrib
Get<T>()/Update() entity tracking changes and issues
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Get() and Update() behavior described in the issue, then inspect SqlMapper.cs around line 417 where the second exception occurs. Reproduce the interface-based Invoice example and determine whether Update() is intended to inspect every property or only changed properties. Done means the tracking behavior and handling of the unchanged Detail property are documented or corrected, with the reported exceptions addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100