Inherited TableAttribute is ignored by CRUD operations

Open
#153 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in src/Dapper.Contrib/SqlMapperExtensions.cs at GetTableName and compare its CustomAttributes handling with the ExplicitKeyAttribute handling around the referenced lines. Verify how inherited TableAttribute values flow through CRUD operations and determine whether those operations should use the inherited table name rather than requiring TableMapper or repeated attributes.

Written by the indexing model from the issue text.

Description

The TableAttribute is inherited to subclasses but then ignored by the CRUD operations. This is due to the method SQLMapperExtensions.GetTableName ignoring inherited CustomAttributes.

https://github.com/DapperLib/Dapper.Contrib/blob/cf24f6bdc577b1e071c3764ddfb2cf3382531405/src/Dapper.Contrib/SqlMapperExtensions.cs#L290-L293

This feels wrong since the attribute is actually being inherited and attributes on property level are not being ignored, e.g.: properties with ExplicitKeyAttribute

https://github.com/DapperLib/Dapper.Contrib/blob/cf24f6bdc577b1e071c3764ddfb2cf3382531405/src/Dapper.Contrib/SqlMapperExtensions.cs#L87-L98

Currently you have to either specify the table name for every subclass or make use of SQLMapperExtensions.TableMapper.
Is this behaviour wanted?

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

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.

More from DapperLib/Dapper.Contrib

All issues in DapperLib/Dapper.Contrib

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.