mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.0 KiB
26 lines
1.0 KiB
using System;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Volo.Abp.MongoDB;
|
|
using Volo.Abp.MongoDB.DependencyInjection;
|
|
|
|
namespace Microsoft.Extensions.DependencyInjection
|
|
{
|
|
public static class AbpMongoDbServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddMongoDbContext<TMongoDbContext>(this IServiceCollection services, Action<IMongoDbContextRegistrationOptionsBuilder> optionsBuilder = null) //Created overload instead of default parameter
|
|
where TMongoDbContext : AbpMongoDbContext
|
|
{
|
|
var options = new MongoDbContextRegistrationOptions(typeof(TMongoDbContext), services);
|
|
optionsBuilder?.Invoke(options);
|
|
|
|
foreach (var dbContextType in options.ReplacedDbContextTypes)
|
|
{
|
|
services.Replace(ServiceDescriptor.Transient(dbContextType, typeof(TMongoDbContext)));
|
|
}
|
|
|
|
new MongoDbRepositoryRegistrar(options).AddRepositories();
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|
|
|