DapperLib / DapperLib/Dapper.Contrib

修复 Dapper.Contrib.Extensions 中 Insert 方法,此方法返回值为long类型,但内部各类型数据库获取自增ID,都是转换为int32,当ID超过超过Int32(2147483647)时,出现bug。

Open
#4 4 comments 2 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

修复 Dapper.Contrib.Extensions 中 Insert 方法,此方法返回值为long类型,但内部各类型数据库获取自增ID,都是转换为int32,当ID超过超过Int32(2147483647)时,出现bug。

主要涉及到的内容为接口 ISqlAdapter 中的方法:

`
///


/// The interface for all Dapper.Contrib database operations
/// Implementing this is each provider's model.
///

public partial interface ISqlAdapter
{
///
/// Inserts into the database, returning the Id of the row created.
///

/// The connection to use.
/// The transaction to use.
/// The command timeout to use.
/// The table to insert into.
/// The columns to set with this insert.
/// The parameters to set for this insert.
/// The key columns in this table.
/// The entity to insert.
/// The Id of the row created.
int Insert(IDbConnection connection, IDbTransaction transaction, int? commandTimeout, string tableName, string columnList, string parameterList, IEnumerable keyProperties, object entityToInsert);

....
`

,此方法返回值改为long可修复此问题。

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 with the ISqlAdapter interface and its Insert method, then locate the database-provider implementations that return generated IDs. Trace the conversions used for each provider and update the return path so IDs above Int32.MaxValue remain supported. Done means the interface and all implementations consistently return long values without narrowing the generated ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
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.