DapperLib / DapperLib/Dapper

Mapping a date field to a string property of record

Open
#1,670 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

I am trying to migrate all my classes to record because it is much more convenient and during that I found a case which works fine on class type but not record:

Structure of record:
public record Foo(string EffectiveDate);
OR
public record Foo() {
public string EffectiveDate { get; set; }
}

Structure of class
public class Foo {
public string EffectiveDate { get; set; }
}

My MSSQL table is using Date data type for EffectiveDate, when I tried to query by using dapper then it throws an exception said it can't match the record which doesn't happened when using class.

Is there a workaround to get through? Thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported difference between the shown C# record and class when mapping the MSSQL Date field EffectiveDate with Dapper. Compare the mapping behavior and determine whether the record maps successfully or whether a documented workaround is needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.