This is especially important when you want to **override a base repository method** to customize it. For instance, you may want to override `DeleteAsync` method to delete an entity in a more efficient way:
Isso é especialmente importante quando você deseja dar **override em um método da base repository** para customizar. Por exemplo, você pode querer substituir o método `DeleteAsync` para excluir uma entidade de uma forma mais eficiente:
```csharp
public async override Task DeleteAsync(
@ -248,13 +248,13 @@ public async override Task DeleteAsync(
bool autoSave = false,
CancellationToken cancellationToken = default)
{
//TODO: Custom implementation of the delete method
// TODO: Implementação customizada do método delete
}
```
### Access to the MongoDB API
### Acesso à API MongoDB
In most cases, you want to hide MongoDB APIs behind a repository (this is the main purpose of the repository). However, if you want to access the MongoDB API over the repository, you can use `GetDatabaseAsync()`, `GetCollectionAsync()` or `GetAggregateAsync()` extension methods. Example:
Na maioria dos casos, você vai querer ocultar APIs do MongoDB atrás de uma repository (este é o objetivo principal da repository). No entanto, se você quiser acessar a API MongoDB através da Repository, você pode usar os métodos de extensão `GetDatabaseAsync()`, `GetCollectionAsync()` ou `GetAggregateAsync()`. Exemplo:
If your solution is [multi-tenant](Multi-Tenancy.md), tenants may have **separate databases**, you have **multiple**`DbContext` classes in your solution and some of your `DbContext` classes should be usable **only from the host side**, it is suggested to add `[IgnoreMultiTenancy]` attribute on your `DbContext` class. In this case, ABP guarantees that the related `DbContext` always uses the host [connection string](Connection-Strings.md), even if you are in a tenant context.
**Example:**
**Exemplo:**
````csharp
[IgnoreMultiTenancy]
@ -310,7 +310,7 @@ Do not use the `[IgnoreMultiTenancy]` attribute if any one of your entities in y
> When you use repositories, ABP already uses the host database for the entities don't implement the `IMultiTenant` interface. So, most of time you don't need to `[IgnoreMultiTenancy]` attribute if you are using the repositories to work with the database.
#### Set Default Repository Classes
#### Definir Classes Repository Padrão
Default generic repositories are implemented by `MongoDbRepository` class by default. You can create your own implementation and use it for default repository implementation.
@ -417,7 +417,7 @@ In this example, `OtherMongoDbContext` implements `IBookStoreMongoDbContext`. Th
### Personalizar Operações em Massa
If you have better logic or using an external library for bulk operations, you can override the logic via implementing`IMongoDbBulkOperationProvider`.
Se você tiver uma lógica melhor ou usar uma biblioteca externa para operações em massa, pode substituir a lógica por meio da implementação de`IMongoDbBulkOperationProvider`.
- Você pode usar o modelo de exemplo abaixo:
@ -433,7 +433,7 @@ public class MyCustomMongoDbBulkOperationProvider
CancellationToken cancellationToken)
where TEntity : class, IEntity
{
// Your logic here.
// Sua lógica aqui.
}
public async Task InsertManyAsync<TEntity>(
@ -444,7 +444,7 @@ public class MyCustomMongoDbBulkOperationProvider
CancellationToken cancellationToken)
where TEntity : class, IEntity
{
// Your logic here.
// Sua lógica aqui.
}
public async Task UpdateManyAsync<TEntity>(
@ -455,7 +455,7 @@ public class MyCustomMongoDbBulkOperationProvider