Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Oct 03, 2019 @ 07:57
    Ismail Mayat
    0

    NPoco in v8 save issue

    I am trying to save some stuff to cmstags table using npoco from Umbraco.

    My code looks like this:

                    using (var scope = _scopeProvider.CreateScope(autoComplete: true))
                {
                    using (var transaction = scope.Database.GetTransaction())
                    {
                        scope.Database.InsertBulk(newTags);
                        transaction.Complete();
                    }
    
                }
    

    I get the following exception:

    System.InvalidCastException: Unable to cast object of type 'Umbraco.Core.Persistence.FaultHandling.RetryDbConnection' to type 'System.Data.SqlClient.SqlConnection'

    Before the insert I do a read and that works fine. Just does not want to save.

    Anyone seen this before?

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Oct 03, 2019 @ 08:34
    Ismail Mayat
    0

    Ok so fixed this,

                    using (var scope = _scopeProvider.CreateScope(autoComplete: true))
                {
                    using (var transaction = scope.Database.GetTransaction())
                    {
                        scope.Database.InsertBatch(newTags);
                        transaction.Complete();
                    }
    
                }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies