Missing implicit numeric cast of decimal to integer in C# record
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Hi, I've found that Dapper behaves differently when using plain classes or records (working on Oracle 12).
When getting results from a command, like
return await connection.QueryAsync<SomeObject>(query);
this
public class SomeObject
{
public int Id { get; set; }
}
works fine while this
public record SomeObject(int Id)
throws
System.InvalidOperationException: A parameterless default constructor or one matching signature (System.Decimal ID) is required for SomeNamespace.SomeObjectmaterialization
If I change property data type, like this
public record SomeObject(decimal Id)
it works, but I don't want to use decimal instead of int.
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 QueryAsync reproduction in the issue and compare materialization of the class and positional record when the result value is System.Decimal. Done means a record with an int Id can be materialized from that result, while the existing class behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100