DapperLib / DapperLib/DapperAOT

Allow Dapper to enforce 'required' properties are present

Open
#145 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
472
Forks
43
Avg merge
1d 4h
Merged PRs (30d)
18

Description

I would be nice to be able to configure Dapper to respect 'required' annotations:

public class DataResult
{
    public required string StringValue { get; set; }
    public required int IntValue { get; set; }
}

...

await connectionQueryAsync<DataResult>("[proc_MyStoredProc]");
// Should throw an exception if `StringValue` or `IntValue` are not provided

Suggested API changes:

SqlMapper.Settings.RespectRequiredModifiers = true;

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 reviewing DapperAOT's configuration and the mapping path used by connectionQueryAsync. Define how the proposed SqlMapper.Settings.RespectRequiredModifiers setting should behave, then verify that missing required properties cause an exception while supplied properties continue to map successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.