GithubHelp home page GithubHelp logo

Comments (7)

JonathanMagnan avatar JonathanMagnan commented on September 27, 2024 1

Hello @Sashi13 ,

I should have known faster what is the possible cause of this issue.

You are currently using the Dapper Global Context Mapping instead of using an Instance Context Mapping

What this means is that the mapping keeps being modified in a concurrency scenario, which could impact options and mapping when executing the Bulk Insert.

If the mapping is always the same (or you use a mapper key for different mapping, that's perfectly fine to use the global context but somewhere that will only called once, so not in a method.

Could you try again by either:

  • Make sure that the mapping is only done once if you are using the Global Context Mapping
  • By using an Instance Context Mapping in your method

Let me know if the possible cause and solution are clear.

Best Regards,

Jon

from dapper-plus.

JonathanMagnan avatar JonathanMagnan commented on September 27, 2024

Hello @Sashi13 ,

Do you want your key to be generated or not? In your title, you specify BulkInsert doesn't generate primary key, but you use the InsertKeepIdentity = true option (to insert the identity value from your entity, so doesn't generate it).

I believe there is something we do not understand correctly in your request.

Is it possible to have more information or create a runnable project with the issue? It doesn’t need to be your project, just a new solution with the minimum code to reproduce the issue.

Best Regards,

Jon

from dapper-plus.

Sashi13 avatar Sashi13 commented on September 27, 2024

Hi @JonathanMagnan

Thank you for the reply. Sorry I forgot to remove the InsertKeepIdentity option. Anyhow it still didn't fix my problem. The primary key is auto generated by mysql during insert. The problem happens when I try bulkinsert the dapper_item_serial primary key for the data is not auto generated by mysql (the primary key is set to auto increment) and it returns as 0 (exception is thrown during the insert I have attached the exception below). This only happens if multiple user submit the result to the backend at same time. If one user submit at different timestamp then everything runs as intended.

StackTrace:

at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at .(DbCommand , BulkOperation )
   at .( , DbCommand )
   at .Execute(List`1 actions)
   at .(List`1 )
   at Z.BulkOperations.BulkOperation.Execute()
   at Z.BulkOperations.BulkOperation.BulkInsert()
   at Z.Dapper.Plus.DapperPlusAction.Execute()
   at Z.Dapper.Plus.DapperPlusActionSet`1..(Object )
   at System.Collections.Generic.List`1.ForEach(Action`1 action) in /_/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs:line 554
   at Z.Dapper.Plus.DapperPlusExtensions.AlsoBulkInsert[T](IDapperPlusActionSet`1 actionSet, String mapperKey, Func`2[] selectors)
   at Z.Dapper.Plus.DapperPlusExtensions.AlsoBulkInsert[T](IDapperPlusActionSet`1 actionSet, Func`2[] selectors)
   at Antz.Core.V2.Logics.Receiving.<>c__DisplayClass40_4.<UpdatePadiniPairingSerials_Retry>b__15() in D:\Projects\StandardIMS\ANTZ_IMS\Antz.Core\V2\Logics\Receiving.cs:line 8683
   at Polly.ResiliencePipeline.<>c.<Execute>b__28_0(ResilienceContext _, Action state)

Exception:

Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in MySql.Data.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in Z.Dapper.Plus.dll
Exception thrown: 'MySql.Data.MySqlClient.MySqlException' in Z.Dapper.Plus.dll

from dapper-plus.

JonathanMagnan avatar JonathanMagnan commented on September 27, 2024

Hello @Sashi13 ,

My developer tried, but everything worked as expected.

Having a project that reproduces this issue will surely ensure us that we have the same configuration as you. You can send it in private here: [email protected]

Best Regards,

Jon

from dapper-plus.

Sashi13 avatar Sashi13 commented on September 27, 2024

Hi @JonathanMagnan,

I have sent the project file to the specified email. Sorry for the delay.

Thank you

from dapper-plus.

JonathanMagnan avatar JonathanMagnan commented on September 27, 2024

Hello @Sashi13,

Since our last conversation, we haven't heard from you.

Did the solution proposed work?

Let me know if you need further assistance.

Best regards,
Jon

from dapper-plus.

Sashi13 avatar Sashi13 commented on September 27, 2024

Hi sorry for late reply. Yeah it did fix the issue. Thank you.

from dapper-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.