DapperLib / DapperLib/Dapper.Contrib

Adding Dapper.Contrib Attributes to model carries dependency with Dapper library (and dapper.Contrib)

Open
#77 2 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 have been using dapper and dapper.contrib for years. Common use case is you have a project with your POCs. i.e. WhateverCompany.Model. Usual scenario is you expose "some" of this objects to the outside world, i.e. "Products" in the form of a package, so some contracts will carry the "Product" entity.

The problem comes when your customers need to add dapper dependency as it is required for attributes as "ComputedAttribute", "TableAttribute", etc. In few words, packaging the "Model" project will add "Dapper" and "Dapper.Contrib" packages which is not ideal, as you are only decorating one property with an attribute. I.e.:

[Computed]
public DateTime? EffectiveDate { get; set; }

I think it would be ideal if you would package these attributes in a smaller project, so there is not a dependency with the whole Dapper project, or else use reflection in a way that would allow to import (copy) these attributes to the own project, which actually works for the "TableAttribute" but not for the rest of them.

This way the Repo project would need this Dapper dependency, but the Model project and all the referencing clients wouldn't need to add this dependency to the projects.

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 reviewing the definitions and package dependencies for ComputedAttribute, TableAttribute, and the other Dapper.Contrib attributes mentioned in the issue. Determine whether the attributes can be isolated from the main Dapper dependency so model projects can reference them without bringing in Dapper; done means the model package no longer requires those dependencies while repository usage remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.