Copied to clipboard

Flag this post as spam?

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


  • Marius 15 posts 102 karma points
    Dec 21, 2023 @ 18:45
    Marius
    0

    Can't insert into my custom table.

    I am using Umbraco 13 and following this documentation https://docs.umbraco.com/umbraco-cms/extending/database to create custom tables in Umbraco. Custom tables are created in my database but when I trying to insert data to the table using example from the documentation I still getting empty table. There are no errors in console. This is my service

    public async Task AddGlossaryTranslation(GlossaryDto model)
    {
    
        using (var scope = _scopeProvider.CreateScope())
        {
            var db = _scopeAccessor.AmbientScope!.Database;
            db.BeginTransaction();
            try
            {
              await db.InsertAsync<GlossaryDto>(model);
    
                db.CompleteTransaction();
            }
            catch (Exception)
            {
                db.AbortTransaction();
                throw;
            }
            finally
            {
                scope.Complete();
            }
        }  
    }
    
  • Huw Reddick 1932 posts 6722 karma points MVP 2x c-trib
    Dec 21, 2023 @ 22:36
    Huw Reddick
    0

    I think I had the same issues, but changed code to do the following

    scope.Database.Save(mymodel);

  • 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