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 02, 2019 @ 16:42
    Ismail Mayat
    0

    Using ITagRepository in your service

    In the Umbraco core you have ITagRepository this does read write to the umbraco tags table.

    I am trying to pre fill my tags table with some data. I am injecting it into my service. When I try to use it in my service I get error:

    Cannot run a repository without an ambient scope.

    Also looking at the Repository everything passed into it is null. Is it even possible to use it? If not then how do you do npoco stuff in v8 in v7 you could get the database instance and do stuff.

    Regards

    Ismail

  • Kevin Jump 1867 posts 11859 karma points MVP 4x c-trib
    Oct 02, 2019 @ 17:05
    Kevin Jump
    0

    Hi

    When using a repository, you need to wrap the calls in a scope

    using (scopeProvider.CreateScope(autoComplete: true))
    {
           ... call repo here. 
    }
    

    there is some setup in the service to be able to do this. see this https://github.com/KevinJump/DoStuffWithUmbraco/blob/master/Src/DoStuff.Core/RepoPattern/Services/DoStuffBaseService.cs as an example.

  • 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