From 6bd06f6f678093da1faa62068889a100c953b725 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 5 May 2021 15:08:52 +0800 Subject: [PATCH] Update document --- docs/en/Entity-Framework-Core.md | 14 +++++++++++++- docs/en/MongoDB.md | 14 +++++++++++++- docs/zh-Hans/Entity-Framework-Core.md | 14 +++++++++++++- docs/zh-Hans/MongoDB.md | 14 +++++++++++++- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md index a2c0e79996..aced8d406d 100644 --- a/docs/en/Entity-Framework-Core.md +++ b/docs/en/Entity-Framework-Core.md @@ -706,7 +706,19 @@ One advantage of using an interface for a DbContext is then it will be replaceab ### Replace Other DbContextes -Once you properly define and use an interface for DbContext, then any other implementation can replace it using the `ReplaceDbContext` option: +Once you properly define and use an interface for DbContext, then any other implementation can use the following ways to replace it: + +**ReplaceDbContextAttribute** + +```csharp +[ReplaceDbContext(typeof(IBookStoreDbContext))] +public class OtherDbContext : AbpDbContext, IBookStoreDbContext +{ + //... +} +``` + +**ReplaceDbContext option** ````csharp context.Services.AddAbpDbContext(options => diff --git a/docs/en/MongoDB.md b/docs/en/MongoDB.md index a12d216b3d..ae8f5c82d1 100644 --- a/docs/en/MongoDB.md +++ b/docs/en/MongoDB.md @@ -373,7 +373,19 @@ One advantage of using interface for a MongoDbContext is then it becomes replace #### Replace Other DbContextes -Once you properly define and use an interface for a MongoDbContext , then any other implementation can replace it using the `ReplaceDbContext` option: +Once you properly define and use an interface for a MongoDbContext , then any other implementation can use the following ways to replace it: + +**ReplaceDbContextAttribute** + +```csharp +[ReplaceDbContext(typeof(IBookStoreMongoDbContext))] +public class OtherMongoDbContext : AbpMongoDbContext, IBookStoreMongoDbContext +{ + //... +} +``` + +**ReplaceDbContext option** ```csharp context.Services.AddMongoDbContext(options => diff --git a/docs/zh-Hans/Entity-Framework-Core.md b/docs/zh-Hans/Entity-Framework-Core.md index b5252b86c0..4139407f04 100644 --- a/docs/zh-Hans/Entity-Framework-Core.md +++ b/docs/zh-Hans/Entity-Framework-Core.md @@ -433,7 +433,19 @@ public class BookRepository : EfCoreRepository, ### 替换其他仓储 -正确定义并使用DbContext接口后,任何其他实现都可以使用以下ReplaceDbContext options 替换它: +正确定义并使用DbContext接口后,任何其他实现都可以使用以下方法替换它: + +**ReplaceDbContextAttribute** + +```csharp +[ReplaceDbContext(typeof(IBookStoreDbContext))] +public class OtherDbContext : AbpDbContext, IBookStoreDbContext +{ + //... +} +``` + +**ReplaceDbContext option** ````csharp context.Services.AddAbpDbContext(options => diff --git a/docs/zh-Hans/MongoDB.md b/docs/zh-Hans/MongoDB.md index af63642a41..87c99d3207 100644 --- a/docs/zh-Hans/MongoDB.md +++ b/docs/zh-Hans/MongoDB.md @@ -329,7 +329,19 @@ public class BookRepository ##### 替换其他的DbContexts -一旦你正确定义并为MongoDbContext使用了接口,其他的实现就可以使用`ReplaceDbContext`来替换: +一旦你正确定义并为MongoDbContext使用了接口,任何其他实现都可以使用以下方法替换它: + +**ReplaceDbContextAttribute** + +```csharp +[ReplaceDbContext(typeof(IBookStoreMongoDbContext))] +public class OtherMongoDbContext : AbpMongoDbContext, IBookStoreMongoDbContext +{ + //... +} +``` + +**ReplaceDbContext option** ```csharp context.Services.AddMongoDbContext(options =>