Copied to clipboard

Flag this post as spam?

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

  • Marcio Goularte 388 posts 1360 karma points
    Mar 18, 2019 @ 20:41
    Marcio Goularte

    NPoco Fluent Mappings and Performing operations during Poco events with Umbraco 8

    I use NPoco a lot of time and always set up the Pocos using fluent mappings. This mapping runs in DatabaseFactory:

    public void Application_Start()
    public static class MyFactory
        public static DatabaseFactory DbFactory { get; set; }
        public static void Setup()
            var fluentConfig = FluentMappingConfiguration.Configure(new OurMappings());
            //or individual mappings
            //var fluentConfig = FluentMappingConfiguration.Configure(new UserMapping(), ....);
            DbFactory = DatabaseFactory.Config(x =>
                x.UsingDatabase(() => new Database("connString"));
                x.WithMapper(new Mapper());

    Also how is it possible to use interceptors.,-Update,-etc)

    How would that be at Umbraco?

    I made a few attempts using IUserComposer but all failed

  • Alex Skrypnyk 6134 posts 23953 karma points MVP 8x admin c-trib
    Mar 26, 2019 @ 09:30
    Alex Skrypnyk

    Hi Marcio

    Did you find a solution? Can you share with our community?



  • Marcio Goularte 388 posts 1360 karma points
    Apr 01, 2019 @ 00:02
    Marcio Goularte

    Hi Alex,

    I have not found a solution yet without having to modify the Umbraco code. I'm doing some testing. The problem to create the mappings is to create at the time of UmbracoDatabase Setup. I got to making modifications to the source code. I'm seeing a way to do this after the setup or I'll open a PR with the solution I did by changing the source code.

    I modify this part of code

  • Stephen 767 posts 2273 karma points c-trib
    Apr 01, 2019 @ 15:36

    Briefly looked at our code in UmbracoDatabaseFactory and indeed it does not really support adding more mappers and / more tweaking the configuration.

    I'm totally fine with extending it so that we make it more open.

    I am not entirely sure what is the best way to do it, though. Maybe make our own UmbracoDatabaseFactory class public with some virtual extension points, would allow ppl to subclass it - but the factory is not resolved via the normal composers concept, because it needs to be resolved way earlier in the boot process. It is created by CoreRuntime.GetDatabaseFactory so ppl would have to also override the runtime, which means overriding the application base (in global.asax)... not so simple.

    Happy to hear about other ideas.

  • Leon Lindeberg 12 posts 103 karma points
    Oct 08, 2020 @ 12:33
    Leon Lindeberg

    Did you make progress on this? Is there a GitHub issue?

  • Andy Felton 185 posts 484 karma points c-trib
    Mar 08, 2022 @ 16:10
    Andy Felton

    Just wondering did anybody achieve this?

Please Sign in or register to post replies

Write your reply to: