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 10090 karma points MVP 2x admin c-trib
    Oct 03, 2019 @ 07:57
    Ismail Mayat
    0

    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 10090 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();
                    }
    
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft