Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangeeth Nandakumar committed Jan 21, 2024
2 parents a3153b7 + f4e6841 commit 6219fe2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions document.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ There are 2 varients of Twileloop.UOW for LiteDB and MongoDB support

## 1. Register all databases (ASP.NET dependency injection)
```csharp
(For APIs with scopped injection)
//LiteDB
builder.Services.AddUnitOfWork((uow) => {
uow.Connections = new List<LiteDBConnection>
Expand All @@ -68,6 +69,17 @@ builder.Services.AddUnitOfWork((uow) => {
};
});

(For console apps, worker services etc..)
//LiteDB
builder.Services.AddSingletonUnitOfWork((uow) => {
uow.Connections = new List<LiteDBConnection>
{
new LiteDBConnection("DatabaseA", "Filename=DatabaseA.db; Mode=Shared; Password=****;"),
new LiteDBConnection("DatabaseB", "Filename=DatabaseB.db; Mode=Shared; Password=****;")
};
});

(Mongo support for UOW is always injected singleton)
//MongoDB
builder.Services.AddUnitOfWork((uow) => {
uow.Connections = new List<MongoDBConnection>
Expand Down

0 comments on commit 6219fe2

Please sign in to comment.