diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cbc1b9e9..a20787a4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Represents the **NuGet** versions. +## v5.17.1 +- *Fixed:* The database console `Script` command execution has been updated to output to the correct directory path. +- *Fixed:* The `Agent` code-generation artefacts have been further simplified/improved. +- *Fixed:* The database code-generation support for replacement is now optional (see new `Replace` property) versus always (defaults to `true`). + ## v5.17.0 - *Enhancement:* The `Common`-project related code-generated artefacts have all been updated to leverage `global using` and file scoped namespace declarations. - A new [`GlobalUsings.cs`](./templates/Beef.Template.Solution/content/Company.AppName.Common/GlobalUsings.cs) will need to be manually added to existing `Common` projects to enable; see [this](./templates/Beef.Template.Solution/content/Company.AppName.Common/GlobalUsings.cs) for an example and alter the last two namespaces accordingly. diff --git a/Common.targets b/Common.targets index 8d377acea..15e9c25a9 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@ - 5.17.0 + 5.17.1 preview Avanade Avanade diff --git a/docs/Database-Query-Config.md b/docs/Database-Query-Config.md index dc927828f..01c063ba3 100644 --- a/docs/Database-Query-Config.md +++ b/docs/Database-Query-Config.md @@ -46,6 +46,7 @@ Property | Description **`name`** | The name of the primary table of the query. [Mandatory] `schema` | The schema name of the primary table of the view.
† Defaults to `CodeGeneration.Schema`. `alias` | The `Schema.Table` alias name.
† Will automatically default where not specified. +`viewReplace` | Indicates whether the existing `View` database object should be replaced/altered or whether the object is dropped and recreated.
† Defaults to `CodeGeneration.Replace`.
diff --git a/docs/Database-StoredProcedure-Config.md b/docs/Database-StoredProcedure-Config.md index 79f4f8d8c..534c80e37 100644 --- a/docs/Database-StoredProcedure-Config.md +++ b/docs/Database-StoredProcedure-Config.md @@ -66,6 +66,7 @@ Property | Description **`type`** | The stored procedure operation type. Valid options are: `Get`, `GetColl`, `Create`, `Update`, `Upsert`, `Delete`, `Merge`.
† Defaults to `GetColl`. **`paging`** | Indicates whether standardized paging support should be added.
† This only applies where the stored procedure operation `Type` is `GetColl`. `storedProcedureName` | The `StoredProcedure` name in the database.
† Defaults to `sp` + `Table.Name` + `Name`; e.g. `spTableName` or `spPersonGet`. +`replace` | Indicates whether the existing `StoredProcedure` database object should be replaced/altered or whether the object is dropped and recreated.
† Defaults to `CodeGeneration.Replace`.
diff --git a/docs/Database-Table-Config.md b/docs/Database-Table-Config.md index beabec95f..d2d2c57d9 100644 --- a/docs/Database-Table-Config.md +++ b/docs/Database-Table-Config.md @@ -63,6 +63,7 @@ Property | Description **`name`** | The name of the `Table` in the database. [Mandatory] **`schema`** | The name of the `Schema` where the `Table` is defined in the database.
† Defaults to `CodeGeneration.Schema`. `alias` | The `Schema.Table` alias name.
† Will automatically default where not specified. +`replace` | Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.
† Defaults to `CodeGeneration.Replace`.
diff --git a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj index 743fc8bcf..bd88762fc 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj @@ -5,7 +5,7 @@ true
- + diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj index 9fa8d17c5..f5ee3356a 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj @@ -12,8 +12,8 @@ - - - + + +
\ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/AccountAgent.cs b/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/AccountAgent.cs index 454c9cd07..59cb9cb7a 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/AccountAgent.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/AccountAgent.cs @@ -7,33 +7,28 @@ namespace Cdr.Banking.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class AccountAgent : TypedHttpClientBase, IAccountAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class AccountAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IAccountAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public AccountAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAccountsAsync(AccountArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/banking/accounts", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("api/v1/banking/accounts", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> GetAccountsQueryAsync(QueryArgs? query = null, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/banking/accounts/query", requestOptions: requestOptions.IncludeQuery(query).IncludePaging(paging), args: HttpArgs.Create(), cancellationToken: cancellationToken); + => GetAsync("api/v1/banking/accounts/query", requestOptions: requestOptions.IncludeQuery(query).IncludePaging(paging), cancellationToken: cancellationToken); /// public Task> GetDetailAsync(string? accountId, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/banking/accounts/{accountId}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("accountId", accountId)), cancellationToken: cancellationToken); + => GetAsync("api/v1/banking/accounts/{accountId}", requestOptions, [new HttpArg("accountId", accountId)], cancellationToken); /// public Task> GetBalanceAsync(string? accountId, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/banking/accounts/{accountId}/balance", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("accountId", accountId)), cancellationToken: cancellationToken); + => GetAsync("api/v1/banking/accounts/{accountId}/balance", requestOptions, [new HttpArg("accountId", accountId)], cancellationToken); /// public Task GetStatementAsync(string? accountId, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/banking/accounts/{accountId}/statement", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("accountId", accountId)), cancellationToken: cancellationToken); + => GetAsync("api/v1/banking/accounts/{accountId}/statement", requestOptions, [new HttpArg("accountId", accountId)], cancellationToken); } \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/ReferenceDataAgent.cs b/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/ReferenceDataAgent.cs index 877fb7d7f..e3f491501 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/ReferenceDataAgent.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/ReferenceDataAgent.cs @@ -7,39 +7,34 @@ namespace Cdr.Banking.Common.Agents; /// /// Provides the ReferenceData HTTP agent. /// -public partial class ReferenceDataAgent : TypedHttpClientBase, IReferenceDataAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IReferenceDataAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> OpenStatusGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/ref/openstatuses", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/ref/openstatuses", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> ProductCategoryGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/ref/productcategories", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/ref/productcategories", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> AccountUTypeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/ref/accountutypes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/ref/accountutypes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> MaturityInstructionsGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/ref/maturityinstructions", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/ref/maturityinstructions", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> TransactionTypeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/ref/transactiontypes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/ref/transactiontypes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> TransactionStatusGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/ref/transactionstatuses", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/ref/transactionstatuses", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task GetNamedAsync(string[] names, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/TransactionAgent.cs b/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/TransactionAgent.cs index 2b21ac33c..c6bbe9973 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/TransactionAgent.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Agents/Generated/TransactionAgent.cs @@ -7,17 +7,12 @@ namespace Cdr.Banking.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class TransactionAgent : TypedHttpClientBase, ITransactionAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class TransactionAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), ITransactionAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public TransactionAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetTransactionsAsync(string? accountId, TransactionArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/banking/accounts/{accountId}/transactions", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("accountId", accountId), new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("api/v1/banking/accounts/{accountId}/transactions", requestOptions.IncludePaging(paging), [new HttpArg("accountId", accountId), new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); } \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj index ac6240eab..d1ff3b430 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj index 947fa8095..be08da648 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj @@ -39,7 +39,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs b/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs index 1811e6354..46ab9ee1f 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs +++ b/samples/Cdr.Banking/Cdr.Banking.Test/FixtureSetup.cs @@ -26,7 +26,9 @@ public void OneTimeSetUp() if (count == 0) { using var test = ApiTester.Create(); - _cosmosDb = test.Services.GetRequiredService(); + using var scope = test.Services.CreateScope(); + + _cosmosDb = scope.ServiceProvider.GetRequiredService(); await _cosmosDb.Database.Client.CreateDatabaseIfNotExistsAsync(_cosmosDb.Database.Id, cancellationToken: ct).ConfigureAwait(false); diff --git a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj index e14b3bc6f..ecbe0025c 100644 --- a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj +++ b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj @@ -12,7 +12,7 @@ - + diff --git a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj index f2f4e055d..1887a2ba1 100644 --- a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj +++ b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj @@ -16,14 +16,14 @@ - - - - - - - - + + + + + + + + diff --git a/samples/Demo/Beef.Demo.Business/Data/PersonData.cs b/samples/Demo/Beef.Demo.Business/Data/PersonData.cs index e85c9ca09..4e164c212 100644 --- a/samples/Demo/Beef.Demo.Business/Data/PersonData.cs +++ b/samples/Demo/Beef.Demo.Business/Data/PersonData.cs @@ -36,6 +36,7 @@ private async Task MergeOnImplementationAsync(Guid personFromId, Guid pe private Task MarkOnImplementationAsync() { using var scope = _logger.BeginScope(new Dictionary { { "MyKey", "MyValue" } }); + CoreEx.ExecutionContext.Current.Messages.Add(MessageType.Warning, "Software licence is overdue; please pay immediately or services will be halted."); _logger.LogWarning("Mark operation implementation currently does not exist."); return Task.CompletedTask; } diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/ConfigAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/ConfigAgent.cs index d8b4ae2cc..24b05d5b3 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/ConfigAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/ConfigAgent.cs @@ -10,16 +10,11 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the Config HTTP agent. /// -public partial class ConfigAgent : TypedHttpClientBase, IConfigAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ConfigAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IConfigAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ConfigAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetEnvVarsAsync(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) => PostAsync("api/v1/envvars", requestOptions: requestOptions, cancellationToken: cancellationToken); diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/ContactAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/ContactAgent.cs index 092d2b951..8b4a3650e 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/ContactAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/ContactAgent.cs @@ -10,19 +10,14 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class ContactAgent : TypedHttpClientBase, IContactAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ContactAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IContactAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ContactAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetByQueryAsync(QueryArgs? query = null, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/contacts/query", requestOptions: requestOptions.IncludeQuery(query).IncludePaging(paging), args: HttpArgs.Create(), cancellationToken: cancellationToken); + => GetAsync("api/v1/contacts/query", requestOptions: requestOptions.IncludeQuery(query).IncludePaging(paging), cancellationToken: cancellationToken); /// public Task> GetAllAsync(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) @@ -30,27 +25,27 @@ public Task> GetAllAsync(HttpRequestOptions? /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/contacts/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/contacts/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> CreateAsync(Contact value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/contacts", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/contacts", value, requestOptions, cancellationToken: cancellationToken); /// public Task> UpdateAsync(Contact value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/contacts/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/contacts/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("api/v1/contacts/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("api/v1/contacts/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("api/v1/contacts/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("api/v1/contacts/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task RaiseEventAsync(bool throwError, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/contacts/raise", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("throwError", throwError)), cancellationToken: cancellationToken); + => PostAsync("api/v1/contacts/raise", requestOptions, [new HttpArg("throwError", throwError)], cancellationToken); } #pragma warning restore diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/GenderAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/GenderAgent.cs index 7765782c2..273c6ac16 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/GenderAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/GenderAgent.cs @@ -10,27 +10,22 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class GenderAgent : TypedHttpClientBase, IGenderAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class GenderAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IGenderAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public GenderAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/genders/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/demo/ref/genders/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> CreateAsync(Gender value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/demo/ref/genders", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/demo/ref/genders", value, requestOptions, cancellationToken: cancellationToken); /// public Task> UpdateAsync(Gender value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/demo/ref/genders/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/demo/ref/genders/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); } #pragma warning restore diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/PersonAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/PersonAgent.cs index 27a2549de..e16493942 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/PersonAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/PersonAgent.cs @@ -10,47 +10,42 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class PersonAgent : TypedHttpClientBase, IPersonAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class PersonAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IPersonAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public PersonAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> CreateAsync(Person value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/persons", value, requestOptions, cancellationToken: cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("api/v1/persons/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("api/v1/persons/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetExAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/ex/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/ex/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> UpdateAsync(Person value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/persons/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/persons/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> UpdateWithRollbackAsync(Person value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/persons/withRollback/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/persons/withRollback/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("api/v1/persons/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("api/v1/persons/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetAllAsync(PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/all", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/all", requestOptions: requestOptions.IncludePaging(paging), cancellationToken: cancellationToken); /// public Task> GetAll2Async(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) @@ -58,15 +53,15 @@ public Task> GetAll2Async(HttpRequestOptions? /// public Task> GetByArgsAsync(PersonArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> GetDetailByArgsAsync(PersonArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/argsdetail", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/argsdetail", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> MergeAsync(Guid fromId, Guid toId, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/merge", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("fromId", fromId), new HttpArg("toId", toId)), cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/merge", requestOptions, [new HttpArg("fromId", fromId), new HttpArg("toId", toId)], cancellationToken); /// public Task MarkAsync(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) @@ -74,7 +69,7 @@ public Task MarkAsync(HttpRequestOptions? requestOptions = null, Can /// public Task> MapAsync(MapArgs? args, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/map", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/map", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> GetNoArgsAsync(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) @@ -82,27 +77,27 @@ public Task> MapAsync(MapArgs? args, HttpRequestOptio /// public Task> GetDetailAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/{id}/detail", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/{id}/detail", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> UpdateDetailAsync(PersonDetail value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/persons/{id}/detail", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/persons/{id}/detail", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchDetailAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("api/v1/persons/{id}/detail", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("api/v1/persons/{id}/detail", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task AddAsync(Person person, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/fromBody", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("person", person, HttpArgType.FromBody)), cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/fromBody", requestOptions, [new HttpArg("person", person, HttpArgType.FromBody)], cancellationToken); /// public Task Add2Async(Person person, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/acceptsBody", person, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/acceptsBody", person, requestOptions, cancellationToken: cancellationToken); /// public Task Add3Async(Person value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/acceptsBodyValue", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/acceptsBodyValue", value, requestOptions, cancellationToken: cancellationToken); /// public Task CustomManagerOnlyAsync(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) @@ -110,15 +105,15 @@ public Task CustomManagerOnlyAsync(HttpRequestOptions? requestOption /// public Task> GetNullAsync(string? name, List? names, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/null", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("name", name), new HttpArg?>("names", names)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/null", requestOptions, [new HttpArg("name", name), new HttpArg?>("names", names)], cancellationToken); /// public Task> EventPublishNoSendAsync(Person value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/persons/publishnosend", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PutAsync("api/v1/persons/publishnosend", value, requestOptions, cancellationToken: cancellationToken); /// public Task> GetByArgsWithEfAsync(PersonArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/args", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/args", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task ThrowErrorAsync(HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) @@ -126,43 +121,43 @@ public Task ThrowErrorAsync(HttpRequestOptions? requestOptions = nul /// public Task> InvokeApiViaAgentAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/invokeApi", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/invokeApi", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task ParamCollAsync(AddressCollection? addresses, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/paramcoll", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("addresses", addresses, HttpArgType.FromBody)), cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/paramcoll", requestOptions, [new HttpArg("addresses", addresses, HttpArgType.FromBody)], cancellationToken); /// public Task> GetWithEfAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/ef/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/ef/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> CreateWithEfAsync(Person value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/ef", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/ef", value, requestOptions, cancellationToken: cancellationToken); /// public Task> UpdateWithEfAsync(Person value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/persons/ef/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/persons/ef/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteWithEfAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("api/v1/persons/ef/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("api/v1/persons/ef/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchWithEfAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("api/v1/persons/ef/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("api/v1/persons/ef/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task GetDocumentationAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/{id}/documentation", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/{id}/documentation", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> SimulateWorkAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/persons/simulate", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/persons/simulate", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> ExtendResponseAsync(string? name, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/persons/extend-response", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("name", name)), cancellationToken: cancellationToken); + => PostAsync("api/v1/persons/extend-response", requestOptions, [new HttpArg("name", name)], cancellationToken); } #pragma warning restore diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/PostalInfoAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/PostalInfoAgent.cs index ad6641084..0c5f56b51 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/PostalInfoAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/PostalInfoAgent.cs @@ -10,35 +10,30 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class PostalInfoAgent : TypedHttpClientBase, IPostalInfoAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class PostalInfoAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IPostalInfoAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public PostalInfoAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetPostCodesAsync(string? country, string? state, string? city, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/postal/{country}/{state}/{city}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)), cancellationToken: cancellationToken); + => GetAsync("api/v1/postal/{country}/{state}/{city}", requestOptions, [new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)], cancellationToken); /// public Task> CreatePostCodesAsync(PostalInfo value, string? country, string? state, string? city, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/postal/{country}/{state}/{city}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)), cancellationToken: cancellationToken); + => PostAsync("api/v1/postal/{country}/{state}/{city}", value, requestOptions, [new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)], cancellationToken); /// public Task> UpdatePostCodesAsync(PostalInfo value, string? country, string? state, string? city, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/postal/{country}/{state}/{city}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)), cancellationToken: cancellationToken); + => PutAsync("api/v1/postal/{country}/{state}/{city}", value, requestOptions, [new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)], cancellationToken); /// public Task> PatchPostCodesAsync(HttpPatchOption patchOption, string value, string? country, string? state, string? city, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("api/v1/postal/{country}/{state}/{city}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)), cancellationToken: cancellationToken); + => PatchAsync("api/v1/postal/{country}/{state}/{city}", patchOption, value, requestOptions, [new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)], cancellationToken); /// public Task DeletePostCodesAsync(string? country, string? state, string? city, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("api/v1/postal/{country}/{state}/{city}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)), cancellationToken: cancellationToken); + => DeleteAsync("api/v1/postal/{country}/{state}/{city}", requestOptions, [new HttpArg("country", country), new HttpArg("state", state), new HttpArg("city", city)], cancellationToken); } #pragma warning restore diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/ReferenceDataAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/ReferenceDataAgent.cs index 6550d601f..fac089ed7 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/ReferenceDataAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/ReferenceDataAgent.cs @@ -10,47 +10,42 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the ReferenceData HTTP agent. /// -public partial class ReferenceDataAgent : TypedHttpClientBase, IReferenceDataAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IReferenceDataAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> CountryGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/countries", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/countries", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> USStateGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/usStates", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/usStates", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> GenderGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/genders", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/genders", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> EyeColorGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/eyeColors", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/eyeColors", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> PowerSourceGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/powerSources", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/powerSources", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> CompanyGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/companies", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/companies", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> StatusGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/statuses", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/statuses", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> CommunicationTypeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/demo/ref/communicationTypes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("api/v1/demo/ref/communicationTypes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task GetNamedAsync(string[] names, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) diff --git a/samples/Demo/Beef.Demo.Common/Agents/Generated/RobotAgent.cs b/samples/Demo/Beef.Demo.Common/Agents/Generated/RobotAgent.cs index 261a249dd..0c9d98eea 100644 --- a/samples/Demo/Beef.Demo.Common/Agents/Generated/RobotAgent.cs +++ b/samples/Demo/Beef.Demo.Common/Agents/Generated/RobotAgent.cs @@ -10,43 +10,38 @@ namespace Beef.Demo.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class RobotAgent : TypedHttpClientBase, IRobotAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class RobotAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IRobotAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public RobotAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/robots/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("api/v1/robots/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> CreateAsync(Robot value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/robots", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("api/v1/robots", value, requestOptions, cancellationToken: cancellationToken); /// public Task> UpdateAsync(Robot value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("api/v1/robots/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("api/v1/robots/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("api/v1/robots/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("api/v1/robots/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("api/v1/robots/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("api/v1/robots/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetByArgsAsync(RobotArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("api/v1/robots", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("api/v1/robots", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task RaisePowerSourceChangeAsync(Guid id, string? powerSource, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("api/v1/robots/{id}/powerSource/{powerSource}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id), new HttpArg("powerSource", powerSource)), cancellationToken: cancellationToken); + => PostAsync("api/v1/robots/{id}/powerSource/{powerSource}", requestOptions, [new HttpArg("id", id), new HttpArg("powerSource", powerSource)], cancellationToken); } #pragma warning restore diff --git a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj index ce4a4d2c1..7f0846647 100644 --- a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj +++ b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableCreate.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableCreate.sql index f573103c8..3f61bcea0 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableCreate.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableCreate.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableCreate] +CREATE PROCEDURE [Test].[spTableCreate] @TableId AS UNIQUEIDENTIFIER = NULL OUTPUT, @Name AS NVARCHAR(50) NULL = NULL, @Count AS INT NULL = NULL, diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableDelete.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableDelete.sql index f22bf89e2..76f8a0279 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableDelete.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableDelete.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableDelete] +CREATE PROCEDURE [Test].[spTableDelete] @TableId AS UNIQUEIDENTIFIER, @UpdatedBy AS NVARCHAR(250) NULL = NULL, @UpdatedDate AS DATETIME2 NULL = NULL diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGet.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGet.sql index d8fc77c70..0853baeba 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGet.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGet.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableGet] +CREATE PROCEDURE [Test].[spTableGet] @TableId AS UNIQUEIDENTIFIER AS BEGIN diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetAll.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetAll.sql index a798e22fb..e0d115371 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetAll.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetAll.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableGetAll] +CREATE PROCEDURE [Test].[spTableGetAll] AS BEGIN /* diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetByArgs.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetByArgs.sql index 73c85b72e..ad9f1614e 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetByArgs.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableGetByArgs.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableGetByArgs] +CREATE PROCEDURE [Test].[spTableGetByArgs] @Name AS NVARCHAR(50) NULL = NULL, @MinCount AS INT, @MaxCount AS INT NULL = NULL diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableMerge.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableMerge.sql index ea30783e6..216badae8 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableMerge.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableMerge.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableMerge] +CREATE PROCEDURE [Test].[spTableMerge] @List AS [Test].[udtTableList] READONLY AS BEGIN diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpdate.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpdate.sql index f4079cbe8..2ac9207bf 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpdate.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpdate.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableUpdate] +CREATE PROCEDURE [Test].[spTableUpdate] @TableId AS UNIQUEIDENTIFIER, @Name AS NVARCHAR(50) NULL = NULL, @Count AS INT NULL = NULL, diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpsert.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpsert.sql index d643ee255..464a912db 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpsert.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Stored Procedures/Generated/spTableUpsert.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER PROCEDURE [Test].[spTableUpsert] +CREATE PROCEDURE [Test].[spTableUpsert] @TableId AS UNIQUEIDENTIFIER, @Name AS NVARCHAR(50) NULL = NULL, @Count AS INT NULL = NULL, diff --git a/samples/Demo/Beef.Demo.Database/Schema/Test/Views/Generated/vwTestQuery.sql b/samples/Demo/Beef.Demo.Database/Schema/Test/Views/Generated/vwTestQuery.sql index 777148921..ffd9c098c 100644 --- a/samples/Demo/Beef.Demo.Database/Schema/Test/Views/Generated/vwTestQuery.sql +++ b/samples/Demo/Beef.Demo.Database/Schema/Test/Views/Generated/vwTestQuery.sql @@ -1,4 +1,4 @@ -CREATE OR ALTER VIEW [Test].[vwTestQuery] +CREATE VIEW [Test].[vwTestQuery] AS /* * This is automatically generated; any changes will be lost. diff --git a/samples/Demo/Beef.Demo.Database/database.beef-5.yaml b/samples/Demo/Beef.Demo.Database/database.beef-5.yaml index 75474c755..2a09ab68a 100644 --- a/samples/Demo/Beef.Demo.Database/database.beef-5.yaml +++ b/samples/Demo/Beef.Demo.Database/database.beef-5.yaml @@ -6,7 +6,7 @@ collectionType: UDT queries: # New "Query" configuration. -- { name: Table, schema: Test, view: true, viewName: vwTestQuery, excludeColumns: [ CreatedBy, UpdatedBy ], permission: TestSec, +- { name: Table, schema: Test, view: true, viewName: vwTestQuery, viewReplace: false, excludeColumns: [ CreatedBy, UpdatedBy ], permission: TestSec, joins: [ { name: Person, schema: Demo, excludeColumns: [ CreatedDate, UpdatedDate ], aliasColumns: [ RowVersion^RowVersionP ], on: [ @@ -35,7 +35,7 @@ tables: - { name: Table3, schema: Test, get: true, create: true, update: true, delete: true, upsert: true } # Special test to generate all variations. -- { name: Table, schema: Test, create: true, update: true, upsert: true, delete: true, merge: true, udt: true, getAll: true, getAllOrderBy: [ Name Des ], excludeColumns: [ Other ], orgUnitImmutable: true, permission: TestSec, +- { name: Table, schema: Test, create: true, update: true, upsert: true, delete: true, merge: true, udt: true, getAll: true, replace: false, getAllOrderBy: [ Name Des ], excludeColumns: [ Other ], orgUnitImmutable: true, permission: TestSec, storedProcedures: [ { name: GetByArgs, type: GetColl, excludeColumns: [ Count ], parameters: [ diff --git a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj index ac24e7ca7..46061949e 100644 --- a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj +++ b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj @@ -52,7 +52,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Demo/Beef.Demo.Test/PersonTest.cs b/samples/Demo/Beef.Demo.Test/PersonTest.cs index 18ca24637..754764973 100644 --- a/samples/Demo/Beef.Demo.Test/PersonTest.cs +++ b/samples/Demo/Beef.Demo.Test/PersonTest.cs @@ -1209,10 +1209,17 @@ public void I120_Mark() .ExpectEvent("Demo.Mark", "Marked") .Run(a => a.MarkAsync()); - AgentTester.Test() + var hr = AgentTester.Test() .ExpectStatusCode(HttpStatusCode.Accepted) .ExpectEvent(new EventData { Subject = "Demo.Mark", Action = "Marked", Value = "Wahlberg" }) - .Run(a => a.MarkAsync()); + .Run(a => a.MarkAsync()) + .Result; + + Assert.That(hr.Messages, Is.Not.Null); + Assert.That(hr.Messages, Has.Count.EqualTo(1)); + Assert.That(hr.Messages[0].Type, Is.EqualTo(MessageType.Warning)); + Assert.That(hr.Messages[0].Text, Is.EqualTo("Software licence is overdue; please pay immediately or services will be halted.")); + } [Test, TestSetUp] diff --git a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj index 0d5313a30..b5450bbb7 100644 --- a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj +++ b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj @@ -5,7 +5,7 @@ true - + diff --git a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj index b06e96089..180dc43b3 100644 --- a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj +++ b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj @@ -6,10 +6,10 @@ latest - - - - + + + + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Common/Agents/Generated/EmployeeAgent.cs b/samples/My.Hr/My.Hr.Common/Agents/Generated/EmployeeAgent.cs index 133ca5159..605d9e109 100644 --- a/samples/My.Hr/My.Hr.Common/Agents/Generated/EmployeeAgent.cs +++ b/samples/My.Hr/My.Hr.Common/Agents/Generated/EmployeeAgent.cs @@ -7,41 +7,36 @@ namespace My.Hr.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class EmployeeAgent : TypedHttpClientBase, IEmployeeAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class EmployeeAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IEmployeeAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public EmployeeAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("employees/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> CreateAsync(Employee value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("employees", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("employees", value, requestOptions, cancellationToken: cancellationToken); /// public Task> UpdateAsync(Employee value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("employees/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("employees/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("employees/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("employees/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("employees/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("employees/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetByArgsAsync(EmployeeArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("employees", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> TerminateAsync(TerminationDetail value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("employees/{id}/terminate", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PostAsync("employees/{id}/terminate", value, requestOptions, [new HttpArg("id", id)], cancellationToken); } \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs b/samples/My.Hr/My.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs index c73fd1400..186473044 100644 --- a/samples/My.Hr/My.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs +++ b/samples/My.Hr/My.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs @@ -7,37 +7,32 @@ namespace My.Hr.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class PerformanceReviewAgent : TypedHttpClientBase, IPerformanceReviewAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class PerformanceReviewAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IPerformanceReviewAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public PerformanceReviewAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("reviews/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("reviews/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetByEmployeeIdAsync(Guid employeeId, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees/{employeeId}/reviews", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("employeeId", employeeId)), cancellationToken: cancellationToken); + => GetAsync("employees/{employeeId}/reviews", requestOptions.IncludePaging(paging), [new HttpArg("employeeId", employeeId)], cancellationToken); /// public Task> CreateAsync(PerformanceReview value, Guid employeeId, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("employees/{employeeId}/reviews", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("employeeId", employeeId)), cancellationToken: cancellationToken); + => PostAsync("employees/{employeeId}/reviews", value, requestOptions, [new HttpArg("employeeId", employeeId)], cancellationToken); /// public Task> UpdateAsync(PerformanceReview value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("reviews/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("reviews/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("reviews/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("reviews/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("reviews/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("reviews/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); } \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Common/Agents/Generated/ReferenceDataAgent.cs b/samples/My.Hr/My.Hr.Common/Agents/Generated/ReferenceDataAgent.cs index cfb7173b0..e8657b33d 100644 --- a/samples/My.Hr/My.Hr.Common/Agents/Generated/ReferenceDataAgent.cs +++ b/samples/My.Hr/My.Hr.Common/Agents/Generated/ReferenceDataAgent.cs @@ -7,35 +7,30 @@ namespace My.Hr.Common.Agents; /// /// Provides the ReferenceData HTTP agent. /// -public partial class ReferenceDataAgent : TypedHttpClientBase, IReferenceDataAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IReferenceDataAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GenderGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/genders", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/genders", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> TerminationReasonGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/terminationReasons", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/terminationReasons", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> RelationshipTypeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/relationshipTypes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/relationshipTypes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> USStateGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/usStates", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/usStates", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> PerformanceOutcomeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/performanceOutcomes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/performanceOutcomes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task GetNamedAsync(string[] names, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) diff --git a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj index 0122b62e5..0af66a9bf 100644 --- a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj +++ b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj @@ -6,6 +6,6 @@ true - + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj index 67303f64d..a745e8cf7 100644 --- a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj +++ b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj @@ -32,7 +32,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -42,7 +42,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj index b77f20f4c..a67e2b5a1 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj @@ -6,8 +6,8 @@ True - - + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/GlobalUsings.cs b/samples/MyEf.Hr/MyEf.Hr.Business/GlobalUsings.cs index 9d478143a..e5b46286b 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/GlobalUsings.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/GlobalUsings.cs @@ -39,4 +39,5 @@ global using MyEf.Hr.Business.Data; global using MyEf.Hr.Business.DataSvc; global using MyEf.Hr.Business.Validation; -global using RefDataNamespace = MyEf.Hr.Business.Entities; \ No newline at end of file +global using RefDataNamespace = MyEf.Hr.Business.Entities; +global using ExecutionContext = CoreEx.ExecutionContext; \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj index 2ac37858c..a724b01e3 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj @@ -6,10 +6,10 @@ latest - - - - + + + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Validation/EmployeeValidator.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Validation/EmployeeValidator.cs index 66f820698..a6dad7f63 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Validation/EmployeeValidator.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Validation/EmployeeValidator.cs @@ -34,7 +34,7 @@ public EmployeeValidator(IEmployeeDataSvc employeeDataSvc) Property(x => x.FirstName).Mandatory().Common(CommonValidators.PersonName); Property(x => x.LastName).Mandatory().Common(CommonValidators.PersonName); Property(x => x.Gender).Mandatory().IsValid(); - Property(x => x.Birthday).Mandatory().CompareValue(CompareOperator.LessThanEqual, _ => CoreEx.ExecutionContext.SystemTime.UtcNow.AddYears(-18), errorText: "Birthday is invalid as the Employee must be at least 18 years of age."); + Property(x => x.Birthday).Mandatory().CompareValue(CompareOperator.LessThanEqual, _ => ExecutionContext.Current.Timestamp.Date.AddYears(-18), errorText: "Birthday is invalid as the Employee must be at least 18 years of age."); Property(x => x.StartDate).Mandatory().CompareValue(CompareOperator.GreaterThanEqual, new DateTime(1999, 01, 01, 0, 0, 0, DateTimeKind.Utc), "January 1, 1999"); Property(x => x.PhoneNo).Mandatory().Common(CommonValidators.PhoneNo); Property(x => x.Address).Entity(_addressValidator); @@ -70,9 +70,9 @@ protected override Task OnValidateAsync(ValidationContext cont public static CommonValidator CanDelete { get; } = CommonValidator.Create(cv => cv.CustomAsync((context, _) => { // Unable to use inheritance DI for a Common Validator so the ExecutionContext.GetService will get/create the instance in the same manner. - return Result.GoAsync(CoreEx.ExecutionContext.GetRequiredService().GetAsync(context.Value)) + return Result.GoAsync(ExecutionContext.GetRequiredService().GetAsync(context.Value)) .When(existing => existing is null, _ => Result.NotFoundError()) - .When(existing => existing!.StartDate <= CoreEx.ExecutionContext.Current.Timestamp, _ => Result.ValidationError("An employee cannot be deleted after they have started their employment.")) + .When(existing => existing!.StartDate <= ExecutionContext.Current.Timestamp, _ => Result.ValidationError("An employee cannot be deleted after they have started their employment.")) .AsResult(); })); } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Validation/PerformanceReviewValidator.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Validation/PerformanceReviewValidator.cs index ff2bb66e7..984592f26 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Validation/PerformanceReviewValidator.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Validation/PerformanceReviewValidator.cs @@ -17,7 +17,7 @@ public PerformanceReviewValidator(IPerformanceReviewManager performanceReviewMan _employeeManager = employeeManager ?? throw new ArgumentNullException(nameof(employeeManager)); Property(x => x.EmployeeId).Mandatory(); - Property(x => x.Date).Mandatory().CompareValue(CompareOperator.LessThanEqual, _ => CoreEx.ExecutionContext.Current.Timestamp, _ => "today"); + Property(x => x.Date).Mandatory().CompareValue(CompareOperator.LessThanEqual, _ => ExecutionContext.Current.Timestamp, _ => "today"); Property(x => x.Notes).String(4000); Property(x => x.Reviewer).Mandatory().String(256); Property(x => x.Outcome).Mandatory().IsValid(); @@ -39,7 +39,7 @@ protected override async Task OnValidateAsync(ValidationContext v is null, _ => Result.NotFoundError()).ConfigureAwait(false); if (prr.IsFailure) - return prr.AsResult(); + return prr.Bind(); if (context.Value.EmployeeId != prr.Value.EmployeeId) return Result.Done(() => context.AddError(x => x.EmployeeId, ValidatorStrings.ImmutableFormat)); diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/EmployeeAgent.cs b/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/EmployeeAgent.cs index d93200eb9..8cb496f5c 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/EmployeeAgent.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/EmployeeAgent.cs @@ -7,45 +7,40 @@ namespace MyEf.Hr.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class EmployeeAgent : TypedHttpClientBase, IEmployeeAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class EmployeeAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IEmployeeAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public EmployeeAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("employees/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> CreateAsync(Employee value, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("employees", value, requestOptions: requestOptions, cancellationToken: cancellationToken); + => PostAsync("employees", value, requestOptions, cancellationToken: cancellationToken); /// public Task> UpdateAsync(Employee value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("employees/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("employees/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("employees/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("employees/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("employees/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("employees/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetByArgsAsync(EmployeeArgs? args, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("args", args, HttpArgType.FromUriUseProperties)), cancellationToken: cancellationToken); + => GetAsync("employees", requestOptions.IncludePaging(paging), [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> GetByQueryAsync(QueryArgs? query = null, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees/query", requestOptions: requestOptions.IncludeQuery(query).IncludePaging(paging), args: HttpArgs.Create(), cancellationToken: cancellationToken); + => GetAsync("employees/query", requestOptions: requestOptions.IncludeQuery(query).IncludePaging(paging), cancellationToken: cancellationToken); /// public Task> TerminateAsync(TerminationDetail value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("employees/{id}/terminate", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PostAsync("employees/{id}/terminate", value, requestOptions, [new HttpArg("id", id)], cancellationToken); } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs b/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs index 5434e5ac4..5230f878e 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/PerformanceReviewAgent.cs @@ -7,37 +7,32 @@ namespace MyEf.Hr.Common.Agents; /// /// Provides the HTTP agent. /// -public partial class PerformanceReviewAgent : TypedHttpClientBase, IPerformanceReviewAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class PerformanceReviewAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IPerformanceReviewAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public PerformanceReviewAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GetAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("reviews/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => GetAsync("reviews/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> UpdateAsync(PerformanceReview value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PutAsync("reviews/{id}", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PutAsync("reviews/{id}", value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> PatchAsync(HttpPatchOption patchOption, string value, Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PatchAsync("reviews/{id}", patchOption, value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => PatchAsync("reviews/{id}", patchOption, value, requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task DeleteAsync(Guid id, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => DeleteAsync("reviews/{id}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("id", id)), cancellationToken: cancellationToken); + => DeleteAsync("reviews/{id}", requestOptions, [new HttpArg("id", id)], cancellationToken); /// public Task> GetByEmployeeIdAsync(Guid employeeId, PagingArgs? paging = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("employees/{employeeId}/reviews", requestOptions: requestOptions.IncludePaging(paging), args: HttpArgs.Create(new HttpArg("employeeId", employeeId)), cancellationToken: cancellationToken); + => GetAsync("employees/{employeeId}/reviews", requestOptions.IncludePaging(paging), [new HttpArg("employeeId", employeeId)], cancellationToken); /// public Task> CreateAsync(PerformanceReview value, Guid employeeId, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => PostAsync("employees/{employeeId}/reviews", value, requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("employeeId", employeeId)), cancellationToken: cancellationToken); + => PostAsync("employees/{employeeId}/reviews", value, requestOptions, [new HttpArg("employeeId", employeeId)], cancellationToken); } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/ReferenceDataAgent.cs b/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/ReferenceDataAgent.cs index 8d77d825a..a8cb2c560 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/ReferenceDataAgent.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Common/Agents/Generated/ReferenceDataAgent.cs @@ -7,35 +7,30 @@ namespace MyEf.Hr.Common.Agents; /// /// Provides the ReferenceData HTTP agent. /// -public partial class ReferenceDataAgent : TypedHttpClientBase, IReferenceDataAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IReferenceDataAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - /// public Task> GenderGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/genders", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/genders", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> TerminationReasonGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/terminationreasons", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/terminationreasons", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> RelationshipTypeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/relationshiptypes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/relationshiptypes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> USStateGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/usstates", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/usstates", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task> PerformanceOutcomeGetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync("ref/performanceoutcomes", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync("ref/performanceoutcomes", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); /// public Task GetNamedAsync(string[] names, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj index bb7037712..5628145b7 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj @@ -7,6 +7,6 @@ true - + \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj index 6aed65293..97c6b2f3a 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/OktaHttpClient.cs b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/OktaHttpClient.cs index 73799b213..875089373 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/OktaHttpClient.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/OktaHttpClient.cs @@ -2,12 +2,7 @@ public class OktaHttpClient : TypedHttpClientBase { - public OktaHttpClient(HttpClient client, SecuritySettings settings, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) - : base(client, jsonSerializer, executionContext) - { - Client.BaseAddress = new Uri(settings.OktaHttpClientBaseUri); - DefaultOptions.EnsureSuccess().ThrowKnownException(); - } + public OktaHttpClient(HttpClient client) : base(client) => DefaultOptions.EnsureSuccess().ThrowKnownException(); /// /// Gets the identifier for the email (see ). diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/Startup.cs b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/Startup.cs index a9baa38b9..a787363bc 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/Startup.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/Startup.cs @@ -30,6 +30,10 @@ public override void ConfigureServices(IServiceCollection services) { o.EventDataDeserializationErrorHandling = ErrorHandling.HandleBySubscriber; }) - .AddTypedHttpClient("OktaApi").AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(retryCount: 3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))); ; + .AddTypedHttpClient("OktaApi", (sp, hc) => + { + var settings = sp.GetRequiredService(); + hc.BaseAddress = new Uri(settings.OktaHttpClientBaseUri); + }).AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(retryCount: 3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))); } } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj index a65e342e7..722b853c1 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj @@ -27,7 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj index 703ad80b2..a276dc531 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj @@ -32,7 +32,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -42,7 +42,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/MyEf.Hr/docs/10-Service-Bus-Subscribe.md b/samples/MyEf.Hr/docs/10-Service-Bus-Subscribe.md index 50bcc0fc2..1495468f7 100644 --- a/samples/MyEf.Hr/docs/10-Service-Bus-Subscribe.md +++ b/samples/MyEf.Hr/docs/10-Service-Bus-Subscribe.md @@ -149,7 +149,11 @@ The aforementioned services registration code of interest is as follows. { o.EventDataDeserializationErrorHandling = ErrorHandling.HandleBySubscriber; }) -.AddTypedHttpClient("OktaApi"); +.AddTypedHttpClient("OktaApi", (sp, hc) => +{ + var settings = sp.GetRequiredService(); + hc.BaseAddress = new Uri(settings.OktaHttpClientBaseUri); +}).AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(retryCount: 3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))); ```
@@ -252,12 +256,7 @@ namespace MyEf.Hr.Security.Subscriptions; public class OktaHttpClient : TypedHttpClientBase { - public OktaHttpClient(HttpClient client, SecuritySettings settings, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) - : base(client, jsonSerializer, executionContext) - { - Client.BaseAddress = new Uri(settings.OktaHttpClientBaseUri); - DefaultOptions.EnsureSuccess().ThrowKnownException(); - } + public OktaHttpClient(HttpClient client) : base(client) => DefaultOptions.EnsureSuccess().ThrowKnownException(); /// /// Gets the identifier for the email (see ). diff --git a/templates/Beef.Template.Solution/content/.template.config/template.json b/templates/Beef.Template.Solution/content/.template.config/template.json index 0851327ad..8d4ab85c6 100644 --- a/templates/Beef.Template.Solution/content/.template.config/template.json +++ b/templates/Beef.Template.Solution/content/.template.config/template.json @@ -85,7 +85,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "3.27.1" + "value": "3.27.3" }, "replaces": "CoreExVersion" }, @@ -93,7 +93,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "5.17.0" + "value": "5.17.1" }, "replaces": "BeefVersion" }, diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Business/GlobalUsings.cs b/templates/Beef.Template.Solution/content/Company.AppName.Business/GlobalUsings.cs index 84aa09caf..78f13e892 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Business/GlobalUsings.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Business/GlobalUsings.cs @@ -76,4 +76,5 @@ global using Company.AppName.Business.Data; global using Company.AppName.Business.DataSvc; global using Company.AppName.Business.Validation; -global using RefDataNamespace = Company.AppName.Business.Entities; \ No newline at end of file +global using RefDataNamespace = Company.AppName.Business.Entities; +global using ExecutionContext = CoreEx.ExecutionContext; \ No newline at end of file diff --git a/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs b/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs index c60a29f29..45efba000 100644 --- a/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs +++ b/templates/Beef.Template.Solution/content/Company.AppName.Test/Apis/FixtureSetup.cs @@ -40,7 +40,8 @@ public void OneTimeSetUp() if (count == 0) { using var test = ApiTester.Create(); - var cosmosDb = test.Services.GetRequiredService(); + using var scope = test.Services.CreateScope(); + var cosmosDb = scope.ServiceProvider.GetRequiredService(); // Create the Cosmos Db (where not exists). await cosmosDb.Database.Client.CreateDatabaseIfNotExistsAsync(cosmosDb.Database.Id, cancellationToken: ct).ConfigureAwait(false); diff --git a/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs b/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs index ef27d6c62..bf26cd9bc 100644 --- a/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Database/CodeGenConfig.cs @@ -46,6 +46,14 @@ public class CodeGenConfig : ConfigRootBase, ISpecialColumnNames Description = "This is used as the default `Schema` for all child objects.")] public string? Schema { get; set; } + /// + /// Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated. + /// + [JsonPropertyName("replace")] + [CodeGenProperty("Key", Title = "Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.", + Description = "Defaults to `true`.")] + public bool? Replace { get; set; } + #endregion #region Infer @@ -397,6 +405,7 @@ protected override async Task PrepareAsync() await LoadDbTablesConfigAsync().ConfigureAwait(false); Schema = DefaultWhereNull(Schema, () => "dbo"); + Replace = DefaultWhereNull(Replace, () => true); EfModel = DefaultWhereNull(EfModel, () => false); PathBase = DefaultWhereNull(PathBase, () => $"{Company}.{AppName}"); diff --git a/tools/Beef.CodeGen.Core/Config/Database/QueryConfig.cs b/tools/Beef.CodeGen.Core/Config/Database/QueryConfig.cs index 0deb76d2b..e4f0939fe 100644 --- a/tools/Beef.CodeGen.Core/Config/Database/QueryConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Database/QueryConfig.cs @@ -126,6 +126,14 @@ public class QueryConfig : ConfigBase, ITableRefer Description = "Defaults to `Schema`.")] public string? ViewSchema { get; set; } + /// + /// Indicates whether the existing `View` database object should be replaced/altered or whether the object is dropped and recreated. + /// + [JsonPropertyName("viewReplace")] + [CodeGenProperty("Key", Title = "Indicates whether the existing `View` database object should be replaced/altered or whether the object is dropped and recreated.", + Description = "Defaults to `CodeGeneration.Replace`.")] + public bool? ViewReplace { get; set; } + #endregion #region Auth @@ -345,6 +353,7 @@ protected override async Task PrepareAsync() Alias = DefaultWhereNull(Alias, () => new string(StringConverter.ToSentenceCase(Name)!.Split(' ').Select(x => x[..1].ToLower(System.Globalization.CultureInfo.InvariantCulture).ToCharArray()[0]).ToArray())); ViewName = DefaultWhereNull(ViewName, () => "vw" + Name); ViewSchema = DefaultWhereNull(ViewSchema, () => Schema); + ViewReplace = DefaultWhereNull(ViewReplace, () => Parent!.Replace); if (!string.IsNullOrEmpty(Permission) && Permission.Split(".", StringSplitOptions.RemoveEmptyEntries).Length == 1) Permission += ".Read"; diff --git a/tools/Beef.CodeGen.Core/Config/Database/StoredProcedureConfig.cs b/tools/Beef.CodeGen.Core/Config/Database/StoredProcedureConfig.cs index f2d119956..cb54e47c0 100644 --- a/tools/Beef.CodeGen.Core/Config/Database/StoredProcedureConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Database/StoredProcedureConfig.cs @@ -94,6 +94,14 @@ public class StoredProcedureConfig : ConfigBase Description = "Defaults to `sp` + `Table.Name` + `Name`; e.g. `spTableName` or `spPersonGet`.")] public string? StoredProcedureName { get; set; } + /// + /// Indicates whether the existing `StoredProcedure` database object should be replaced/altered or whether the object is dropped and recreated. + /// + [JsonPropertyName("replace")] + [CodeGenProperty("Key", Title = "Indicates whether the existing `StoredProcedure` database object should be replaced/altered or whether the object is dropped and recreated.", + Description = "Defaults to `CodeGeneration.Replace`.")] + public bool? Replace { get; set; } + #endregion #region Additional @@ -301,6 +309,7 @@ protected override async Task PrepareAsync() { CollectionType = DefaultWhereNull(CollectionType, () => Parent!.CollectionType); StoredProcedureName = DefaultWhereNull(StoredProcedureName, () => $"sp{Parent!.Name}{Name}"); + Replace = DefaultWhereNull(Replace, () => Parent!.Replace); Type = DefaultWhereNull(Type, () => "GetColl"); OrgUnitImmutable = DefaultWhereNull(OrgUnitImmutable, () => Parent!.OrgUnitImmutable); Permission = DefaultWhereNull(Permission?.ToUpperInvariant(), () => Parent!.Permission == null ? null : Parent!.Permission!.ToUpperInvariant() + "." + Type switch diff --git a/tools/Beef.CodeGen.Core/Config/Database/TableConfig.cs b/tools/Beef.CodeGen.Core/Config/Database/TableConfig.cs index 57421dc94..d1c112e3e 100644 --- a/tools/Beef.CodeGen.Core/Config/Database/TableConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Database/TableConfig.cs @@ -85,6 +85,14 @@ public class TableConfig : ConfigBase, ITableRefer Description = "Will automatically default where not specified.")] public string? Alias { get; set; } + /// + /// Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated. + /// + [JsonPropertyName("replace")] + [CodeGenProperty("Key", Title = "Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.", + Description = "Defaults to `CodeGeneration.Replace`.")] + public bool? Replace { get; set; } + #endregion #region Columns @@ -504,6 +512,7 @@ protected override async Task PrepareAsync() throw new CodeGenException(this, nameof(Name), $"Specified Schema.Table '{CodeGenConfig.FormatSchemaTableName(Schema, Name)}' not found in database."); Alias = DefaultWhereNull(Alias, () => new string(StringConverter.ToSentenceCase(Name)!.Split(' ').Select(x => x[..1].ToLower(System.Globalization.CultureInfo.InvariantCulture).ToCharArray()[0]).ToArray())); + Replace = DefaultWhereNull(Replace, () => Parent!.Replace); EfModel = DefaultWhereNull(EfModel, () => Parent!.EfModel); EfModelName = DefaultWhereNull(EfModelName, () => Root.RenameForDotNet(Name)); OrgUnitImmutable = DefaultWhereNull(OrgUnitImmutable, () => Parent!.OrgUnitImmutable); diff --git a/tools/Beef.CodeGen.Core/Schema/database.beef-5.json b/tools/Beef.CodeGen.Core/Schema/database.beef-5.json index 980c1eb89..8c94c8e4a 100644 --- a/tools/Beef.CodeGen.Core/Schema/database.beef-5.json +++ b/tools/Beef.CodeGen.Core/Schema/database.beef-5.json @@ -12,6 +12,11 @@ "title": "The name of the \u0060Schema\u0060 where the artefacts are defined in, or should be created in, the database.", "description": "This is used as the default \u0060Schema\u0060 for all child objects." }, + "replace": { + "type": "boolean", + "title": "Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.", + "description": "Defaults to \u0060true\u0060." + }, "columnNameIsDeleted": { "type": "string", "title": "The column name for the \u0060IsDeleted\u0060 capability.", @@ -223,6 +228,11 @@ "title": "The \u0060Schema.Table\u0060 alias name.", "description": "Will automatically default where not specified." }, + "replace": { + "type": "boolean", + "title": "Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.", + "description": "Defaults to \u0060CodeGeneration.Replace\u0060." + }, "includeColumns": { "type": "array", "title": "The list of \u0060Column\u0060 names to be included in the underlying generated output.", @@ -440,6 +450,11 @@ "title": "The \u0060StoredProcedure\u0060 name in the database.", "description": "Defaults to \u0060sp\u0060 \u002B \u0060Table.Name\u0060 \u002B \u0060Name\u0060; e.g. \u0060spTableName\u0060 or \u0060spPersonGet\u0060." }, + "replace": { + "type": "boolean", + "title": "Indicates whether the existing \u0060StoredProcedure\u0060 database object should be replaced/altered or whether the object is dropped and recreated.", + "description": "Defaults to \u0060CodeGeneration.Replace\u0060." + }, "reselectStatement": { "type": "string", "title": "The SQL statement to perform the reselect after a \u0060Create\u0060, \u0060Update\u0060 or \u0060Upsert\u0060 stored procedure operation \u0060Type\u0060.", @@ -777,6 +792,11 @@ "title": "The schema name for the \u0060View\u0060.", "description": "Defaults to \u0060Schema\u0060." }, + "viewReplace": { + "type": "boolean", + "title": "Indicates whether the existing \u0060View\u0060 database object should be replaced/altered or whether the object is dropped and recreated.", + "description": "Defaults to \u0060CodeGeneration.Replace\u0060." + }, "permission": { "type": "string", "title": "The permission to be used for security permission checking.", diff --git a/tools/Beef.CodeGen.Core/Templates/EntityWebApiAgent_cs.hbs b/tools/Beef.CodeGen.Core/Templates/EntityWebApiAgent_cs.hbs index a60efd966..d349d547b 100644 --- a/tools/Beef.CodeGen.Core/Templates/EntityWebApiAgent_cs.hbs +++ b/tools/Beef.CodeGen.Core/Templates/EntityWebApiAgent_cs.hbs @@ -13,20 +13,18 @@ namespace {{Root.NamespaceCommon}}.Agents; /// /// Provides the {{{EntityNameSeeComments}}} HTTP agent. /// -public partial class {{Name}}Agent : TypedHttpClientBase<{{Name}}Agent>, I{{Name}}Agent +/// The underlying . +/// The optional . +/// The optional . +public partial class {{Name}}Agent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase<{{Name}}Agent>(client, jsonSerializer, executionContext), I{{Name}}Agent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public {{Name}}Agent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } {{#each WebApiAgentOperations}} + {{#unless @first}} + {{/unless}} /// public {{{AgentOperationTaskReturnType}}} {{Name}}Async({{#ifeq Type 'Patch'}}HttpPatchOption patchOption, {{/ifeq}}{{#each Parameters}}{{{WebApiAgentParameterType}}} {{ArgumentName}}{{#ifor IsPagingArgs IsQueryArgs}} = null{{/ifor}}, {{/each}}HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => {{AgentOperationHttpMethod}}("{{AgentWebApiRoute}}", {{#ifeq Type 'Patch'}}patchOption, {{/ifeq}}{{#if HasValue}}{{ValueParameter.ArgumentName}}, {{/if}}requestOptions: requestOptions{{#if Query}}.IncludeQuery(query){{/if}}{{#if Paging}}.IncludePaging(paging){{/if}}{{#ifne ValueLessParameters.Count 0}}, args: HttpArgs.Create({{#each CoreParameters}}{{#unless @first}}, {{/unless}}new HttpArg<{{{WebApiAgentParameterType}}}>("{{ArgumentName}}", {{ArgumentName}}{{#ifval WebApiAgentFrom}}, HttpArgType.{{WebApiAgentFrom}}{{/ifval}}){{/each}}){{/ifne}}, cancellationToken: cancellationToken); + => {{AgentOperationHttpMethod}}("{{AgentWebApiRoute}}", {{#ifeq Type 'Patch'}}patchOption, {{/ifeq}}{{#if HasValue}}{{ValueParameter.ArgumentName}}, {{else}}{{#ifeq CoreParameters.Count 0}}requestOptions: {{/ifeq}}{{/if}}requestOptions{{#if Query}}.IncludeQuery(query){{/if}}{{#if Paging}}.IncludePaging(paging){{/if}}{{#ifne CoreParameters.Count 0}}, [{{#each CoreParameters}}{{#unless @first}}, {{/unless}}new HttpArg<{{{WebApiAgentParameterType}}}>("{{ArgumentName}}", {{ArgumentName}}{{#ifval WebApiAgentFrom}}, HttpArgType.{{WebApiAgentFrom}}{{/ifval}}){{/each}}], cancellationToken{{else}}, cancellationToken: cancellationToken{{/ifne}}); {{/each}} }{{#if Root.PreprocessorDirectives}} diff --git a/tools/Beef.CodeGen.Core/Templates/ReferenceDataWebApiAgent_cs.hbs b/tools/Beef.CodeGen.Core/Templates/ReferenceDataWebApiAgent_cs.hbs index d18de2faa..2ddd10ad4 100644 --- a/tools/Beef.CodeGen.Core/Templates/ReferenceDataWebApiAgent_cs.hbs +++ b/tools/Beef.CodeGen.Core/Templates/ReferenceDataWebApiAgent_cs.hbs @@ -12,20 +12,15 @@ namespace {{Root.NamespaceCommon}}.Agents; /// /// Provides the ReferenceData HTTP agent. /// -public partial class ReferenceDataAgent : TypedHttpClientBase, IReferenceDataAgent +/// The underlying . +/// The optional . +/// The optional . +public partial class ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : TypedHttpClientBase(client, jsonSerializer, executionContext), IReferenceDataAgent { - /// - /// Initializes a new instance of the class. - /// - /// The underlying . - /// The optional . - /// The optional . - public ReferenceDataAgent(HttpClient client, IJsonSerializer? jsonSerializer = null, CoreEx.ExecutionContext? executionContext = null) : base(client, jsonSerializer, executionContext) { } - {{#each RefDataEntities}} /// public Task> {{Name}}GetAllAsync(ReferenceDataFilter? args = null, HttpRequestOptions? requestOptions = null, CancellationToken cancellationToken = default) - => GetAsync<{{RefDataQualifiedEntityCollectionName}}>("{{WebApiRoutePrefix}}", requestOptions: requestOptions, args: HttpArgs.Create(new HttpArg("args", args!, HttpArgType.FromUriUseProperties)), cancellationToken); + => GetAsync<{{RefDataQualifiedEntityCollectionName}}>("{{WebApiRoutePrefix}}", requestOptions, [new HttpArg("args", args, HttpArgType.FromUriUseProperties)], cancellationToken); {{/each}} /// diff --git a/tools/Beef.Database.Core/Beef.Database.Core.csproj b/tools/Beef.Database.Core/Beef.Database.Core.csproj index 708652a40..5b4cb38a1 100644 --- a/tools/Beef.Database.Core/Beef.Database.Core.csproj +++ b/tools/Beef.Database.Core/Beef.Database.Core.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.Core/MigratorConsoleBase.cs b/tools/Beef.Database.Core/MigratorConsoleBase.cs index a09d6624e..a96ae3638 100644 --- a/tools/Beef.Database.Core/MigratorConsoleBase.cs +++ b/tools/Beef.Database.Core/MigratorConsoleBase.cs @@ -59,10 +59,10 @@ public TSelf DatabaseScript(string script) /// protected override void OnBeforeExecute(CommandLineApplication app) { - ConsoleOptions.Add(nameof(MigrationArgs.ScriptFileName), app.Option("-s|--script", "Script orchestration file name. [CodeGen]", CommandOptionType.SingleValue)); - ConsoleOptions.Add(nameof(MigrationArgs.ConfigFileName), app.Option("-c|--config", "Configuration data file name. [CodeGen]", CommandOptionType.SingleValue)); - ConsoleOptions.Add(nameof(MigrationArgs.ExpectNoChanges), app.Option("-enc|--expect-no-changes", "Indicates to expect _no_ changes in the artefact output (e.g. error within build pipeline). [CodeGen]", CommandOptionType.NoValue)); - ConsoleOptions.Add(nameof(MigrationArgs.IsSimulation), app.Option("-sim|--simulation", "Indicates whether the code-generation is a simulation (i.e. does not update the artefacts). [CodeGen]", CommandOptionType.NoValue)); + ConsoleOptions.Add(nameof(MigrationArgs.ScriptFileName), app.Option("-s|--script", "Script orchestration file name (CodeGen command).", CommandOptionType.SingleValue)); + ConsoleOptions.Add(nameof(MigrationArgs.ConfigFileName), app.Option("-c|--config", "Configuration data file name (CodeGen command).", CommandOptionType.SingleValue)); + ConsoleOptions.Add(nameof(MigrationArgs.ExpectNoChanges), app.Option("-enc|--expect-no-changes", "Indicates to expect _no_ changes in the artefact output; e.g. error within build pipeline (CodeGen command).", CommandOptionType.NoValue)); + ConsoleOptions.Add(nameof(MigrationArgs.IsSimulation), app.Option("-sim|--simulation", "Indicates whether the code-generation is a simulation; i.e. does not update the artefacts (CodeGen command).", CommandOptionType.NoValue)); } /// @@ -78,7 +78,9 @@ protected override void OnBeforeExecute(CommandLineApplication app) return vr; if (Args.OutputDirectory == null) - Args.OutputDirectory = new DirectoryInfo(OnRamp.Console.CodeGenConsole.GetBaseExeDirectory()).Parent; + Args.OutputDirectory = Args.MigrationCommand.HasFlag(MigrationCommand.Script) + ? new DirectoryInfo(OnRamp.Console.CodeGenConsole.GetBaseExeDirectory()) + : new DirectoryInfo(OnRamp.Console.CodeGenConsole.GetBaseExeDirectory()).Parent; if (Args.MigrationCommand.HasFlag(MigrationCommand.CodeGen)) { diff --git a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj index adf266f1f..1057b0d4d 100644 --- a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj +++ b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj b/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj index e9189dc26..1962be137 100644 --- a/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj +++ b/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj index a056c687c..5089faa0b 100644 --- a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj +++ b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableCreate_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableCreate_sql.hbs index 0d96d2c54..254c90cc5 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableCreate_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableCreate_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}, {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableDelete_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableDelete_sql.hbs index 79b647e9b..adc0441cd 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableDelete_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableDelete_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}{{#unless @last}},{{/unless}} {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableGetColl_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableGetColl_sql.hbs index 1eb58aa31..aba56d14c 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableGetColl_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableGetColl_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}{{#if Parent.Paging}},{{else}}{{#unless @last}},{{/unless}}{{/if}}{{#if Collection}}{{#ifeq CollectionType 'JSON'}} -- JSON Array{{/ifeq}}{{/if}} {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableGet_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableGet_sql.hbs index dc40ec4e5..2b79dbebf 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableGet_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableGet_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}{{#unless @last}},{{/unless}} {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableMerge_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableMerge_sql.hbs index 91afca63e..72d362456 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableMerge_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableMerge_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}, {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableUpdate_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableUpdate_sql.hbs index 718929adb..281bcdcc8 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableUpdate_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableUpdate_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}, {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbSpTableUpsert_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbSpTableUpsert_sql.hbs index acee19953..1b8e13770 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbSpTableUpsert_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbSpTableUpsert_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] +CREATE {{#if Replace}}OR ALTER {{/if}}PROCEDURE [{{Parent.Schema}}].[{{StoredProcedureName}}] {{#each ArgumentParameters}} {{ParameterSql}}, {{/each}} diff --git a/tools/Beef.Database.SqlServer/Templates/DbVwQuery_sql.hbs b/tools/Beef.Database.SqlServer/Templates/DbVwQuery_sql.hbs index 25f310873..4c3ece329 100644 --- a/tools/Beef.Database.SqlServer/Templates/DbVwQuery_sql.hbs +++ b/tools/Beef.Database.SqlServer/Templates/DbVwQuery_sql.hbs @@ -1,5 +1,5 @@ {{! Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef }} -CREATE OR ALTER VIEW [{{ViewSchema}}].[{{ViewName}}] +CREATE {{#if ViewReplace}}OR ALTER {{/if}}VIEW [{{ViewSchema}}].[{{ViewName}}] AS /* * This is automatically generated; any changes will be lost. diff --git a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj index 3cd0d9081..4e901fa9b 100644 --- a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj +++ b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj @@ -8,7 +8,7 @@ - +