Skip to content

Commit

Permalink
Update autogen.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jul 30, 2024
1 parent 72f9ae2 commit 983e11d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions MyApp/_pages/autoquery/autogen.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ container.AddSingleton<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider));
```

When using [Endpoint Routing](/endpoint-routing) the DB Factory also needs to be initialized on `GenerateCrudServices`, e.g:
When using [Endpoint Routing](/endpoint-routing) the DB Factory also needs to be initialized on `GenerateCrudServices`, the easiest way to do that would be to register AutoQueryFeature plugin in `Configure.Db.cs` e.g:

```csharp
var dbFactory = new OrmLiteConnectionFactory(
context.Configuration.GetConnectionString("DefaultConnection"),
SqliteDialect.Provider);
container.AddSingleton<IDbConnectionFactory>(c => dbFactory);
public class ConfigureDb : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((context, services) => {
var dbFactory = new OrmLiteConnectionFactory(
context.Configuration.GetConnectionString("DefaultConnection"),
SqliteDialect.Provider);
container.AddSingleton<IDbConnectionFactory>(c => dbFactory);

Plugins.Add(new AutoQueryFeature {
MaxLimit = 1000,
GenerateCrudServices = new GenerateCrudServices {
DbFactory = dbFactory,
}
});
services.AddPlugin(new AutoQueryFeature {
MaxLimit = 1000,
GenerateCrudServices = new GenerateCrudServices {
DbFactory = dbFactory,
}
});
// ...
});
}
```

## Export Code-First DTOs
Expand Down

0 comments on commit 983e11d

Please sign in to comment.