DapperLib / DapperLib/Dapper.Contrib

[Dapper.Contrib - Update] SqlDateTime overflow error

Open
#33 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
293
Forks
109
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm using Dapper v1.50.5 v2.0.30 and Dapper.Contrib v1.50.5 v2.0.30, here is my model:

public class Foo
{
    public int Id { get; set; }
    public string Title { get; set; }
    public DateTime CreatedDate { get; set; }
}

And here is my code for update single record:

using (var db = new SqlConnection(SQLConnection.ConnectionString))
{
    db.Open();

    db.Update(new Foo{ Id = 8, Title = "222" });
}

I got:

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Dapper.Contribmakes SQL happy if I assign some value to CreatedDate, e.g: CreatedDate = DateTime.Now, but it is created date and should not be changed on each update.

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 db.Update call with the Foo model and inspect the Dapper.Contrib update path. Done means updating Title succeeds without assigning CreatedDate and does not overwrite the existing created date.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.