DapperLib / DapperLib/Dapper.Contrib
Exception in Dapper.Contrib SqlMapperExtension during the Insert "Value was either too large or too small for an Int32"
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
Scenario:
When explicitly inserting long value in primary key non identity column getting exception as "Value was either too large or too small for an Int32"
Method:
During the insert, the intermittent value stored in int and later i.e. before returning the value its being converted to long.
long Insert<T>(this IDbConnection connection, T entityToInsert, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
Please find the highlighted information.
Could somebody help me on this.
StackTrace:
at System.Decimal.ToInt32(Decimal d)
at System.Decimal.op_Explicit(Decimal value)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at SqlServerAdapter.Insert(IDbConnection connection, IDbTransaction transaction, Nullable1 commandTimeout, String tableName, String columnList, String parameterList, IEnumerable1 keyProperties, Object entityToInsert)
at Dapper.Contrib.Extensions.SqlMapperExtensions.Insert[T](IDbConnection connection, T entityToInsert, IDbTransaction transaction, Nullable`1 commandTimeout)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Dapper.Contrib.Extensions.SqlMapperExtensions.Insert and the SqlServerAdapter.Insert entry points shown in the stack trace. Reproduce an insert using a long value in a non-identity primary key, then verify that the insert completes and returns the expected value without the Decimal.ToInt32 exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100