Skip to content

Commit 614496d

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 1a0165c + 0aa8b64 commit 614496d

File tree

21 files changed

+679
-192
lines changed

21 files changed

+679
-192
lines changed

MyApp/_pages/autoquery/crud.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,19 @@ Just as you can create [Custom AutoQuery Implementations](/autoquery/rdbms.html#
138138
you can also override AutoQuery CRUD implementations by creating implementations with AutoQuery CRUD Request DTOs and calling the relevate `IAutoQueryDb` method, e.g:
139139

140140
```csharp
141-
public class MyCrudServices : Service
141+
public class MyCrudServices(IAutoQueryDb autoQuery) : Service
142142
{
143-
public IAutoQueryDb AutoQuery { get; set; }
144-
145-
public object Post(CreateRockstar request) => AutoQuery.Create(request, base.Request);
146-
public object Put(UpdateRockstar request) => AutoQuery.Update(request, base.Request);
147-
public object Delete(DeleteRockstar request) => AutoQuery.Delete(request, base.Request);
143+
public object Post(CreateRockstar request) => autoQuery.Create(request, base.Request);
144+
public object Put(UpdateRockstar request) => autoQuery.Update(request, base.Request);
145+
public object Delete(DeleteRockstar request) => autoQuery.Delete(request, base.Request);
148146
}
149147

150148
// Async
151-
public class MyCrudServices : Service
149+
public class MyCrudServices(IAutoQueryDb autoQuery) : Service
152150
{
153-
public IAutoQueryDb AutoQuery { get; set; }
154-
155-
public Task<object> Post(CreateRockstar request) => AutoQuery.CreateAsync(request, base.Request);
156-
public Task<object> Put(UpdateRockstar request) => AutoQuery.UpdateAsync(request, base.Request);
157-
public Task<object> Delete(DeleteRockstar request) => AutoQuery.DeleteAsync(request, base.Request);
151+
public Task<object> Post(CreateRockstar request) => autoQuery.CreateAsync(request, base.Request);
152+
public Task<object> Put(UpdateRockstar request) => autoQuery.UpdateAsync(request, base.Request);
153+
public Task<object> Delete(DeleteRockstar request) => autoQuery.DeleteAsync(request, base.Request);
158154
}
159155
```
160156

@@ -490,15 +486,13 @@ have them you'd need to provide custom implementations that can delegate to thei
490486

491487
```csharp
492488
[ConnectionInfo(NamedConnection = MyDatabases.Reporting)]
493-
public class MyReportingServices : Service
489+
public class MyReportingServices(IAutoQueryDb autoQuery) : Service
494490
{
495-
public IAutoQueryDb AutoQuery { get; set; }
496-
497491
public Task<object> Any(CreateConnectionInfoRockstar request) =>
498-
AutoQuery.CreateAsync(request, Request);
492+
autoQuery.CreateAsync(request, Request);
499493

500494
public Task<object> Any(UpdateConnectionInfoRockstar request) =>
501-
AutoQuery.UpdateAsync(request, Request);
495+
autoQuery.UpdateAsync(request, Request);
502496
}
503497
```
504498

MyApp/_pages/autoquery/index.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,13 @@ public class CustomRockstar
214214
}
215215

216216
// Override with custom implementation
217-
public class MyQueryServices : Service
217+
public class MyQueryServices(IAutoQueryDb autoQuery) : Service
218218
{
219-
public IAutoQueryDb AutoQuery { get; set; }
220-
221219
public async Task<object> Any(QueryRockstarAlbums query)
222220
{
223-
using var db = AutoQuery.GetDb(query, base.Request);
224-
var q = AutoQuery.CreateQuery(query, base.Request, db);
225-
return await AutoQuery.ExecuteAsync(query, q, base.Request, db);
221+
using var db = autoQuery.GetDb(query, base.Request);
222+
var q = autoQuery.CreateQuery(query, base.Request, db);
223+
return await autoQuery.ExecuteAsync(query, q, base.Request, db);
226224
}
227225
}
228226
```

MyApp/_pages/autoquery/rdbms.md

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,23 @@ The behavior of queries can be completely customized by simply providing your ow
9898

9999
```csharp
100100
// Override with custom implementation
101-
public class MyQueryServices : Service
101+
public class MyQueryServices(IAutoQueryDb autoQuery) : Service
102102
{
103-
public IAutoQueryDb AutoQuery { get; set; }
104-
105103
// Sync
106104
public object Any(FindMovies query)
107105
{
108-
using var db = AutoQuery.GetDb(query, base.Request);
109-
var q = AutoQuery.CreateQuery(query, base.Request, db);
110-
return AutoQuery.Execute(query, q, base.Request, db);
106+
using var db = autoQuery.GetDb(query, base.Request);
107+
var q = autoQuery.CreateQuery(query, base.Request, db);
108+
return autoQuery.Execute(query, q, base.Request, db);
111109
}
112110

113111
// Async
114112
public async Task<object> Any(QueryRockstars query)
115113
{
116-
using var db = AutoQuery.GetDb(query, base.Request);
117-
var q = AutoQuery.CreateQuery(query, base.Request, db);
118-
return await AutoQuery.ExecuteAsync(query, q, base.Request, db);
119-
}
114+
using var db = autoQuery.GetDb(query, base.Request);
115+
var q = autoQuery.CreateQuery(query, base.Request, db);
116+
return await autoQuery.ExecuteAsync(query, q, base.Request, db);
117+
}
120118
}
121119
```
122120

@@ -1078,14 +1076,12 @@ public class QueryPosts : QueryDb<Post>
10781076
}
10791077

10801078
[CacheResponse(Duration = 600)]
1081-
public class PostPublicServices : PostServicesBase
1079+
public class PostPublicServices(IAutoQueryDb autoQuery) : Service
10821080
{
1083-
public IAutoQueryDb AutoQuery { get; set; }
1084-
10851081
public object Any(QueryPosts request)
10861082
{
1087-
using var db = AutoQuery.GetDb(query, base.Request);
1088-
var q = AutoQuery.CreateQuery(query, base.Request, db) //Populated SqlExpression
1083+
using var db = autoQuery.GetDb(query, base.Request);
1084+
var q = autoQuery.CreateQuery(query, base.Request, db) //Populated SqlExpression
10891085
10901086
q.Where(x => x.Deleted == null);
10911087

@@ -1197,11 +1193,9 @@ E.g. This implementation applies the `[ConnectionInfo]` behavior to all its Serv
11971193

11981194
```csharp
11991195
[ConnectionInfo(NamedConnection = "Reporting")]
1200-
public class MyReportingServices : Service
1196+
public class MyReportingServices(IAutoQueryDb autoQuery) : Service
12011197
{
1202-
public IAutoQueryDb AutoQuery { get; set; }
1203-
1204-
public Task<object> Any(CreateReport request) => AutoQuery.CreateAsync(request, base.Request);
1198+
public Task<object> Any(CreateReport request) => autoQuery.CreateAsync(request,base.Request);
12051199
}
12061200
```
12071201

@@ -1338,15 +1332,13 @@ Where it's also queryable with:
13381332
We've already covered some of extensibility options with Customizable **QueryDbFields** and **Implicit Conventions**, the most customizable would be to override the default implementation with a custom one, e.g:
13391333

13401334
```csharp
1341-
public class MyQueryServices : Service
1335+
public class MyQueryServices(IAutoQueryDb autoQuery) : Service
13421336
{
1343-
public IAutoQueryDb AutoQuery { get; set; }
1344-
13451337
//Override with custom implementation
13461338
public object Any(FindMovies dto)
13471339
{
1348-
var q = AutoQuery.CreateQuery(dto, Request.GetRequestParams(), base.Request);
1349-
return AutoQuery.Execute(dto, q, base.Request);
1340+
var q = autoQuery.CreateQuery(dto, Request.GetRequestParams(), base.Request);
1341+
return autoQuery.Execute(dto, q, base.Request);
13501342
}
13511343
}
13521344
```
@@ -1430,19 +1422,17 @@ Plugins.Add(new AutoQueryFeature {
14301422
It also wont generate implementations for custom AutoBatch implementations, e.g. you can add a custom implementation that does what the generated implementation would've done and execute using the same DB Connection and Transaction with:
14311423

14321424
```csharp
1433-
public class CustomAutoQueryServices : Service
1425+
public class CustomAutoQueryServices(IAutoQueryDb autoQuery) : Service
14341426
{
1435-
public IAutoQueryDb AutoQuery { get; set; }
1436-
14371427
public object Any(CreateItem[] requests)
14381428
{
1439-
using var db = AutoQuery.GetDb<Item>(Request);
1429+
using var db = autoQuery.GetDb<Item>(Request);
14401430
using var dbTrans = db.OpenTransaction();
14411431

14421432
var results = new List<object>();
14431433
foreach (var request in requests)
14441434
{
1445-
var response = await AutoQuery.CreateAsync(request, Request, db);
1435+
var response = await autoQuery.CreateAsync(request, Request, db);
14461436
results.Add(response);
14471437
}
14481438

MyApp/_pages/background-jobs.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,31 +635,31 @@ public class NotifyCheckUrlsCommand(IHttpClientFactory clientFactory)
635635
`ReplyTo` can be any URL which by default will have the result POST'ed back to the URL with a JSON
636636
Content-Type. Typically URLs will contain a reference Id so external clients can correlate a callback
637637
with the internal process that initiated the job. If the callback API is publicly available you'll
638-
want to use an internal Id that can't be guessed so the callback can't be spoofed, like a Guid, e.g:
638+
want to use an internal Id that can't be guessed (like a Guid) so the callback can't be spoofed, e.g:
639639

640-
`$"https://api.example.com?refId={RefId}"`
640+
`$"https://api.example.com/callback?refId={RefId}"`
641641

642642
If needed the callback URL can be customized on how the HTTP Request callback is sent.
643643

644644
If the URL contains a space, the text before the space is treated as the HTTP method:
645645

646-
`"PUT https://api.example.com"`
646+
`"PUT https://api.example.com/callback"`
647647

648648
If the auth part contains a colon `:` it's treated as Basic Auth:
649649

650-
`"username:password@https://api.example.com"`
650+
`"username:password@https://api.example.com/callback"`
651651

652652
If name starts with `http.` sends a HTTP Header
653653

654-
`"http.X-API-Key:myApiKey@https://api.example.com"`
654+
`"http.X-API-Key:myApiKey@https://api.example.com/callback"`
655655

656656
Otherwise it's sent as a Bearer Token:
657657

658-
`"myToken123@https://api.example.com"`
658+
`"myToken123@https://api.example.com/callback"`
659659

660660
Bearer Token or HTTP Headers starting with `$` is substituted with Environment Variable if exists:
661661

662-
`"$API_TOKEN@https://api.example.com"`
662+
`"$API_TOKEN@https://api.example.com/callback"`
663663

664664
When needed headers, passwords and tokens can be URL encoded if they contain any delimiter characters.
665665

MyApp/_pages/releases/v4_0_56.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,8 @@ public class QueryCustomers : QueryDb<Customer>
725725
public int? OrAgeOlderThan { get; set; }
726726
}
727727

728-
public class AutoQueryRDBMSServices : Service
728+
public class AutoQueryRDBMSServices(IAutoQueryDb autoQuery) : Service
729729
{
730-
public IAutoQueryDb AutoQuery { get; set; }
731730
...
732731
}
733732

@@ -739,9 +738,8 @@ public class QueryCustomers : QueryData<Customer>
739738
public int? OrAgeOlderThan { get; set; }
740739
}
741740

742-
public class AutoQueryDataServices : Service
741+
public class AutoQueryDataServices(IAutoQueryData autoQuery) : Service
743742
{
744-
public IAutoQueryData AutoQuery { get; set; }
745743
...
746744
}
747745
```

MyApp/_pages/releases/v5_09.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,15 +1390,13 @@ have them you'd need to provide custom implementations that can delegate to thei
13901390

13911391
```csharp
13921392
[ConnectionInfo(NamedConnection = MyDatabases.Reporting)]
1393-
public class MyReportingServices : Service
1393+
public class MyReportingServices(IAutoQueryDb autoQuery) : Service
13941394
{
1395-
public IAutoQueryDb AutoQuery { get; set; }
1396-
13971395
public Task<object> Any(CreateConnectionInfoRockstar request) =>
1398-
AutoQuery.CreateAsync(request, Request);
1396+
autoQuery.CreateAsync(request, Request);
13991397

14001398
public Task<object> Any(UpdateConnectionInfoRockstar request) =>
1401-
AutoQuery.UpdateAsync(request, Request);
1399+
autoQuery.UpdateAsync(request, Request);
14021400
}
14031401
```
14041402

@@ -3441,10 +3439,8 @@ E.g. This implementation applies the `[ConnectionInfo]` behavior to all its Serv
34413439

34423440
```csharp
34433441
[ConnectionInfo(NamedConnection = "Reporting")]
3444-
public class MyReportingServices : Service
3442+
public class MyReportingServices(IAutoQueryDb autoQuery) : Service
34453443
{
3446-
public IAutoQueryDb AutoQuery { get; set; }
3447-
34483444
public Task<object> Any(CreateReport request) => AutoQuery.CreateAsync(request, base.Request);
34493445
}
34503446
```
@@ -3458,9 +3454,9 @@ There's a minor optimization existing custom AutoQuery implementations can do by
34583454
// Sync
34593455
public object Any(QueryRockstars query)
34603456
{
3461-
using var db = AutoQuery.GetDb(query, base.Request);
3462-
var q = AutoQuery.CreateQuery(query, base.Request, db);
3463-
return await AutoQuery.Execute(query, q, base.Request, db);
3457+
using var db = autoQuery.GetDb(query, base.Request);
3458+
var q = autoQuery.CreateQuery(query, base.Request, db);
3459+
return await autoQuery.Execute(query, q, base.Request, db);
34643460
}
34653461
```
34663462

@@ -3470,9 +3466,9 @@ Another optimization if using SQL Server or PostgreSQL RDBMS's is to refactor it
34703466
// Async
34713467
public async Task<object> Any(QueryRockstars query)
34723468
{
3473-
using var db = AutoQuery.GetDb(query, base.Request);
3474-
var q = AutoQuery.CreateQuery(query, base.Request, db);
3475-
return await AutoQuery.ExecuteAsync(query, q, base.Request, db);
3469+
using var db = autoQuery.GetDb(query, base.Request);
3470+
var q = autoQuery.CreateQuery(query, base.Request, db);
3471+
return await autoQuery.ExecuteAsync(query, q, base.Request, db);
34763472
}
34773473
```
34783474

MyApp/_pages/releases/v5_12.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,19 +2327,17 @@ Plugins.Add(new AutoQueryFeature {
23272327
It also wont generate implementations for custom AutoBatch implementations, e.g. you can add a custom implementation that does what the generated implementation would've done and execute using the same DB Connection and Transaction with:
23282328

23292329
```csharp
2330-
public class CustomAutoQueryServices : Service
2330+
public class CustomAutoQueryServices(IAutoQueryDb autoQuery) : Service
23312331
{
2332-
public IAutoQueryDb AutoQuery { get; set; }
2333-
23342332
public object Any(CreateItem[] requests)
23352333
{
2336-
using var db = AutoQuery.GetDb<Item>(Request);
2334+
using var db = autoQuery.GetDb<Item>(Request);
23372335
using var dbTrans = db.OpenTransaction();
23382336

23392337
var results = new List<object>();
23402338
foreach (var request in requests)
23412339
{
2342-
var response = await AutoQuery.CreateAsync(request, Request, db);
2340+
var response = await autoQuery.CreateAsync(request, Request, db);
23432341
results.Add(response);
23442342
}
23452343

0 commit comments

Comments
 (0)