DapperLib / DapperLib/Dapper.Contrib
writing non-primary key id field
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
given the below simplified class:
[Table ("TableName")]
public class ClassName
{
[ExplicitKey]
public Guid PKId { get; set; }
public string Id { get; set; }
}
dapper contrib's Insert seems to be skipping the Id writing completely.
and for whatever it's worth, the naming convention around this particular table is out of my control.
i just had another thought in that i tried the following and it worked:
[Table ("TableName")]
public class ClassName
{
[Key]
[ExplicitKey]
public Guid PKId { get; set; }
public string Id { get; set; }
}
however, the PKID field is indeed set by the application, not the database so having [ExplicitKey] is more appropriate
any thoughts on this behavior?
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 at the Insert entry point and reproduce the shown ClassName mapping, comparing [ExplicitKey] with the version that also has [Key]. Check whether the non-primary-key Id is omitted from the generated insert. Done means Insert writes Id while leaving the application-assigned PKId behavior intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100