Browse Source

Merge pull request #5468 from abpframework/liangshiwei/patch-1

Disabled mongodb unit of work transaction by default
pull/5509/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
a00571d1e2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      docs/en/Getting-Started.md
  2. 4
      docs/en/MongoDB.md
  3. 13
      docs/zh-Hans/Getting-Started.md
  4. 4
      docs/zh-Hans/MongoDB.md
  5. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs
  6. 6
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs

13
docs/en/Getting-Started.md

@ -115,6 +115,19 @@ abp new Acme.BookStore{{if UI == "NG"}} -u angular{{else if UI == "Blazor"}} -u
The solution has a layered structure (based on the [Domain Driven Design](Domain-Driven-Design.md)) and contains unit & integration test projects. See the [application template document](Startup-Templates/Application.md) to understand the solution structure in details.
{{ if DB == "Mongo" }}
> The [startup template](Startup-templates/Index.md) **disabled** unit of work transaction in the `.MongoDB` project by default. If your MongoDB server supported transaction, you can enable the `transaction` of unit of work manually:
```csharp
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled;
});
```
{{ end }}
## Create the Database
### Connection String

4
docs/en/MongoDB.md

@ -279,12 +279,12 @@ public class BookService
Starting from version 4.0, MongoDB supports transactions. ABP added support for MongoDB transactions in version 3.2. If you upgrade the project to version 3.2. You need add [MongoDbSchemaMigrator](https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs) to your `.MongoDB` project.
If you are using MongoDB server version less then v4.0, you need disabled the `transaction` of unit of work manually:
The [startup template](Startup-templates/Index.md) **disabled** unit of work transaction in the `.MongoDB` project by default. If your MongoDB server supported transaction, you can enable the `transaction` of unit of work manually:
```csharp
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled;
});
```

13
docs/zh-Hans/Getting-Started.md

@ -153,6 +153,19 @@ abp new Acme.BookStore{{if UI == "NG"}} -u angular {{end}}{{if DB == "Mongo"}} -
> 请参阅[应用程序模板文档](Startup-Templates/Application.md)详细了解解决方案结构.
{{ if DB == "Mongo" }}
> [启动模板](Startup-templates/Index.md)默认在 `.MongoDB` 项目中**禁用**了工作单元事务. 如果你的MongoDB服务器支持事务,你可以手动启用工作单元的事务:
```csharp
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled;
});
```
{{ end }}
## 创建数据库
### 连接字符串

4
docs/zh-Hans/MongoDB.md

@ -237,12 +237,12 @@ public class BookService
MongoDB在4.0版本开始支持事务, ABP在3.2版本加入了对MongoDb事务的支持. 如果你升级到3.2版本,需要将[MongoDbSchemaMigrator](https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs)添加到你的 `.MongoDB` 项目中.
如果你在使用4.0版本之前的MongdoDB数据库,你需要手动禁用工作单元的事务:
[启动模板](Startup-templates/Index.md)默认在 `.MongoDB` 项目中**禁用**了工作单元事务. 如果你的MongoDB服务器支持事务,你可以手动启用工作单元的事务:
```csharp
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled;
});
```

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs

@ -8,6 +8,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.MongoDB;
using Volo.Abp.SettingManagement.MongoDB;
using Volo.Abp.TenantManagement.MongoDB;
using Volo.Abp.Uow;
namespace MyCompanyName.MyProjectName.MongoDB
{
@ -30,6 +31,11 @@ namespace MyCompanyName.MyProjectName.MongoDB
{
options.AddDefaultRepositories();
});
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
}
}

6
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs

@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.MongoDB;
using Volo.Abp.Uow;
namespace MyCompanyName.MyProjectName.MongoDB
{
@ -18,6 +19,11 @@ namespace MyCompanyName.MyProjectName.MongoDB
* options.AddRepository<Question, MongoQuestionRepository>();
*/
});
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
}
}

Loading…
Cancel
Save