49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
|
using JiShe.CollectBus.Repository;
|
|
using JiShe.CollectBus.Repository.MeterReadingRecord;
|
|
using JiShe.CollectBus.ShardingStrategy;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using System;
|
|
using Volo.Abp;
|
|
using Volo.Abp.AuditLogging.MongoDB;
|
|
using Volo.Abp.BackgroundJobs.MongoDB;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Domain.Repositories.MongoDB;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.MongoDB;
|
|
using Volo.Abp.Uow;
|
|
|
|
namespace JiShe.CollectBus.MongoDB;
|
|
|
|
[DependsOn(
|
|
typeof(CollectBusDomainModule),
|
|
typeof(AbpMongoDbModule),
|
|
typeof(AbpBackgroundJobsMongoDbModule),
|
|
typeof(AbpAuditLoggingMongoDbModule)
|
|
)]
|
|
public class CollectBusMongoDbModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
context.Services.AddMongoDbContext<CollectBusMongoDbContext>(options =>
|
|
{
|
|
options.AddDefaultRepositories(includeAllEntities: true);
|
|
|
|
// 注册分表策略
|
|
context.Services.AddTransient(
|
|
typeof(IShardingStrategy<>),
|
|
typeof(DayShardingStrategy<>));
|
|
|
|
//// 分表策略仓储 替换默认仓储
|
|
//options.AddRepository<MeterReadingRecords, MeterReadingRecordRepository>();
|
|
});
|
|
|
|
context.Services.AddAlwaysDisableUnitOfWorkTransaction();
|
|
Configure<AbpUnitOfWorkDefaultOptions>(options =>
|
|
{
|
|
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
|
|
});
|
|
}
|
|
}
|