DapperLib / DapperLib/Dapper.Contrib

Dapper Contrib - doesnt insert into database unless all fields values are provided.

Open
#75 1 comment 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

I am using Dapper Contrib to Insert values into table. The insert doesnt happen unless you provide all Entity property values.

Here is my entity:

[Table("Order")]
public class Order
{
    [Key]
    public int OrderId { get; set; }
    public int Quantity { get; set; }
    public decimal? Price { get; set; }
    public string PaymentType { get; set; }

}

Here is my Table

CREATE TABLE [dbo].[Order](
[OrderId] [int] IDENTITY(1,1) NOT NULL,
[Quantity] [int] NOT NULL,
[Price] [money] NULL,
[PaymentType] nvarchar NULL
)

Here PaymentType is nullable but unless i pass PaymentType as empty string in the code. dapper contrib doesnt make an insert to table.

Let me know if anyone has faced this.

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 insert with the shown C# Order entity and SQL Server table, comparing the nullable PaymentType case with the empty-string case. Trace Dapper Contrib's insert behavior to determine why the row is not created, then verify the corrected behavior with a regression test using this entity and schema.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.