public static Configure EntityFrameworkSagaPersister <T>(this Configure config, EntityFrameworkSessionFactory sessionFactory) where T : class, ISagaEntity { config.Configurer.RegisterSingleton <EntityFrameworkSessionFactory>(sessionFactory); config.Configurer.ConfigureComponent <EntityFrameworkMessageModule> (ComponentCallModelEnum.Singleton); config.Configurer.ConfigureComponent <EntityFrameworkSagaPersister <T> > (ComponentCallModelEnum.Singlecall); return(config); }
public static void ConfigureIncodingEFDataServices(this IServiceCollection services, Type entityType, Action <DbContextOptionsBuilder <IncDbContext> > builderConfigure, Action <Func <string, IncDbContext> > onCreated = null) { services.AddSingleton <IUnitOfWorkFactory, EntityFrameworkUnitOfWorkFactory>(); Func <string, IncDbContext> incDbContext = (cs) => { var dbContextOptionsBuilder = new DbContextOptionsBuilder <IncDbContext>(); builderConfigure(dbContextOptionsBuilder); return(new IncDbContext(dbContextOptionsBuilder.Options, entityType.Assembly)); }; onCreated?.Invoke(incDbContext); EntityFrameworkSessionFactory sessionFactory = new EntityFrameworkSessionFactory(incDbContext); services.AddSingleton <IEntityFrameworkSessionFactory>(sessionFactory); }