Skip to content

Commit 983e11d

Browse files
committed
Update autogen.md
1 parent 72f9ae2 commit 983e11d

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

MyApp/_pages/autoquery/autogen.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,27 @@ container.AddSingleton<IDbConnectionFactory>(c =>
4444
new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider));
4545
```
4646

47-
When using [Endpoint Routing](/endpoint-routing) the DB Factory also needs to be initialized on `GenerateCrudServices`, e.g:
47+
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:
4848

4949
```csharp
50-
var dbFactory = new OrmLiteConnectionFactory(
51-
context.Configuration.GetConnectionString("DefaultConnection"),
52-
SqliteDialect.Provider);
53-
container.AddSingleton<IDbConnectionFactory>(c => dbFactory);
50+
public class ConfigureDb : IHostingStartup
51+
{
52+
public void Configure(IWebHostBuilder builder) => builder
53+
.ConfigureServices((context, services) => {
54+
var dbFactory = new OrmLiteConnectionFactory(
55+
context.Configuration.GetConnectionString("DefaultConnection"),
56+
SqliteDialect.Provider);
57+
container.AddSingleton<IDbConnectionFactory>(c => dbFactory);
5458

55-
Plugins.Add(new AutoQueryFeature {
56-
MaxLimit = 1000,
57-
GenerateCrudServices = new GenerateCrudServices {
58-
DbFactory = dbFactory,
59-
}
60-
});
59+
services.AddPlugin(new AutoQueryFeature {
60+
MaxLimit = 1000,
61+
GenerateCrudServices = new GenerateCrudServices {
62+
DbFactory = dbFactory,
63+
}
64+
});
65+
// ...
66+
});
67+
}
6168
```
6269

6370
## Export Code-First DTOs

0 commit comments

Comments
 (0)