DapperLib / DapperLib/Dapper.Contrib
Insert/Update of interfaced type
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
I'm found some error in Insert/Update operation if I pass interfaced type.
public int SaveAbstract(IObjectBase item)
{
item._Updated = DateTime.UtcNow;
if (item.ID > 0) c.Update(item, transaction: tr, commandTimeout: commandTimeout);
else item.ID = (int)c.Insert(item, transaction: tr, commandTimeout: commandTimeout);
cache.Remove(item.GetType().FullName.makeCacheKey());
return item.ID;
}
Currently, Update and Insert method can't find table attribute on IObjectBase and substitute object class name. I'm start investigate and found some lines in this methods:
var type = typeof(T);
I think this line need to be replaced to entityToUpdate.GetType() because Insert/Update need to be know real type of passed item. After changes Insert/Update working correctly.
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 with the Insert and Update methods referenced in the issue and inspect how typeof(T) is used to resolve the table attribute. Reproduce the SaveAbstract(IObjectBase item) path with an implementing object, then verify that both operations resolve the concrete type and complete successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100