0
hungvt created
- ABP Framework version: v3.2.0 I used UnitOfWorkTransactionBehavior.Disabled for mongoDb project, then UnitOfWorkTransactionBehavior of mysql as disable. How to disable only Mongo project. Configure<AbpUnitOfWorkDefaultOptions>(options => { options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; }); Thank!
3 Answer(s)
-
0
Hi,
There is no good way to disable yet, You can replace the
UnitOfWorkMongoDbContextProvider
class and removeCreateDbContextWithTransaction
method -
0
Thank, How to replace the UnitOfWorkMongoDbContextProvider class?
-
0
Try
[Dependency(ReplaceServices = true)] public class MyUnitOfWorkMongoDbContextProvider<TMongoDbContext> : UnitOfWorkMongoDbContextProvider<TMongoDbContext> where TMongoDbContext : IAbpMongoDbContext { public MyUnitOfWorkMongoDbContextProvider(IUnitOfWorkManager unitOfWorkManager, IConnectionStringResolver connectionStringResolver) : base(unitOfWorkManager, connectionStringResolver) { } public new TMongoDbContext CreateDbContextWithTransaction( IUnitOfWork unitOfWork, MongoUrl url, MongoClient client, IMongoDatabase database) { var dbContext = unitOfWork.ServiceProvider.GetRequiredService<TMongoDbContext>(); dbContext.ToAbpMongoDbContext().InitializeDatabase(database, null); return dbContext; } }