DapperLib / DapperLib/Dapper.Contrib

Dapper.Contrib cannot handle GUID primary keys & SqlMapperExtensions.Insert<T> has wrong usage int & long

Open
#5 9 comments 1 reaction 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

SqlMapperExtensions.Insert will fail when numeric db keys reach the Int32 limit (yes, this happens on high traffic dbs) and also fails completely since it assumes primary keys are integers. If primary keys are not integers (i.e. GUIDs or something else) the library fails completely.
Is there any interest for an improvement? I have some proposition in mind.

`        /// <summary>
        /// Inserts an entity into table "Ts" and returns identity id or number of inserted rows if inserting a list.
        /// </summary>
        /// <typeparam name="T">The type to insert.</typeparam>
        /// <param name="connection">Open SqlConnection</param>
        /// <param name="entityToInsert">Entity to insert, can be list of entities</param>
        /// <param name="transaction">The transaction to run under, null (the default) if none</param>
        /// <param name="commandTimeout">Number of seconds before command execution timeout</param>
        /// **<returns>Identity of inserted entity, or number of inserted rows if inserting a list</returns>**
        public static **long** Insert<T>(this IDbConnection connection, T entityToInsert, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
`

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 inspecting the SqlMapperExtensions.Insert entry point and its XML return documentation. Reproduce inserts with a numeric key near the Int32 limit and with a GUID primary key, then define regression coverage showing that both cases return the documented result without failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.