Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled mongodb unit of work transaction by default #5468

Merged
merged 1 commit into from
Sep 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/en/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ Integration tests projects are properly configured to work with in-memory **Mong

> 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
Expand Down
4 changes: 2 additions & 2 deletions docs/en/MongoDB.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
```

Expand Down
13 changes: 13 additions & 0 deletions docs/zh-Hans/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

## 创建数据库

### 连接字符串
Expand Down
4 changes: 2 additions & 2 deletions docs/zh-Hans/MongoDB.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Volo.Abp.PermissionManagement.MongoDB;
using Volo.Abp.SettingManagement.MongoDB;
using Volo.Abp.TenantManagement.MongoDB;
using Volo.Abp.Uow;

namespace MyCompanyName.MyProjectName.MongoDB
{
Expand All @@ -30,6 +31,11 @@ public override void ConfigureServices(ServiceConfigurationContext context)
{
options.AddDefaultRepositories();
});

Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.MongoDB;
using Volo.Abp.Uow;

namespace MyCompanyName.MyProjectName.MongoDB
{
Expand All @@ -18,6 +19,11 @@ public override void ConfigureServices(ServiceConfigurationContext context)
* options.AddRepository<Question, MongoQuestionRepository>();
*/
});

Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
}
}