Exemple #1
0
 public EFRepositoryProvider(
     IServiceProvider serviceProvider,
     DomainMetadata domainMetadata,
     IObjectAccessor <MiCakeEFCoreOptions> options)
 {
     _serviceProvider        = serviceProvider;
     _aggregateRootsMetadata = domainMetadata.DomainObject.AggregateRoots;
     _options = options.Value;
 }
        /// <summary>
        /// Add MiCake EFCore services.
        /// </summary>
        /// <param name="builder"><see cref="IMiCakeBuilder"/></param>
        /// <param name="miCakeDbContextType"><see cref="MiCakeDbContext"/></param>
        /// <param name="optionsBulder">The config for MiCake EFCore extension</param>
        /// <returns><see cref="IMiCakeBuilder"/></returns>
        public static IMiCakeBuilder UseEFCore(
            this IMiCakeBuilder builder,
            Type miCakeDbContextType,
            Action <MiCakeEFCoreOptions> optionsBulder)
        {
            MiCakeEFCoreOptions options = new MiCakeEFCoreOptions(miCakeDbContextType);

            optionsBulder?.Invoke(options);

            builder.ConfigureApplication((app, services) =>
            {
                //register ef module to micake module collection
                app.ModuleManager.AddMiCakeModule(typeof(MiCakeEFCoreModule));

                services.AddSingleton <IObjectAccessor <MiCakeEFCoreOptions> >(options);
            });

            return(builder);
        }