Skip to content

Commit 3cf39f9

Browse files
committed
[ksqlDb.RestApi.Client]: added KSqlDBRestApiClientOptions doc section
1 parent b0f63f2 commit 3cf39f9

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

docs/statements.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,3 +1254,60 @@ var response = await Context.SaveChangesAsync();
12541254
```SQL
12551255
INSERT INTO Movies (Title, Id, Release_Year) VALUES (INITCAP('One little mouse'), 5, 0);
12561256
```
1257+
1258+
### Default ShouldPluralizeFromItemName setting for KSqlDbRestApiClient
1259+
**v6.2.0**
1260+
1261+
Here's the improved version of the text:
1262+
1263+
The `KSqlDbRestApiClient` class now includes `KSqlDBRestApiClientOptions` in its constructor arguments.
1264+
Additionally, `EntityCreationMetadata.ShouldPluralizeEntityName` has been changed to a nullable boolean, and its default value of `true` has been removed.
1265+
The methods in `KSqlDbRestApiClient` check if the `ShouldPluralizeEntityName` field in the `TypeProperties`, `DropTypeProperties`, `InsertProperties`, and `DropFromItemProperties` classes is null, and if so, set it using the value from `KSqlDBRestApiClientOptions`.
1266+
1267+
```C#
1268+
using ksqlDB.RestApi.Client.KSql.Query.Context;
1269+
using ksqlDB.RestApi.Client.KSql.RestApi;
1270+
using ksqlDB.RestApi.Client.KSql.RestApi.Http;
1271+
1272+
var ksqlDbUrl = "http://localhost:8088";
1273+
1274+
var httpClient = new HttpClient
1275+
{
1276+
BaseAddress = new Uri(ksqlDbUrl)
1277+
};
1278+
var httpClientFactory = new HttpClientFactory(httpClient);
1279+
var restApiClientOptions = new KSqlDBRestApiClientOptions
1280+
{
1281+
ShouldPluralizeFromItemName = true,
1282+
};
1283+
1284+
var restApiClient = new KSqlDbRestApiClient(httpClientFactory, restApiClientOptions);
1285+
```
1286+
1287+
To use dependency injection (DI), first create and configure an instance of `KSqlDBRestApiClientOptions`.
1288+
Then, register this configured instance with the service collection.
1289+
1290+
```C#
1291+
using ksqlDb.RestApi.Client.DependencyInjection;
1292+
using ksqlDB.RestApi.Client.KSql.Query.Context;
1293+
using ksqlDB.RestApi.Client.KSql.Query.Options;
1294+
using Microsoft.Extensions.DependencyInjection;
1295+
1296+
var servicesCollection = new ServiceCollection();
1297+
1298+
servicesCollection.AddDbContext<IKSqlDBContext, KSqlDBContext>(
1299+
options =>
1300+
{
1301+
var ksqlDbUrl = "http://localhost:8088";
1302+
var setupParameters = options.UseKSqlDb(ksqlDbUrl);
1303+
1304+
setupParameters.SetAutoOffsetReset(AutoOffsetReset.Earliest);
1305+
1306+
}, contextLifetime: ServiceLifetime.Transient, restApiLifetime: ServiceLifetime.Transient);
1307+
1308+
var restApiClientOptions = new KSqlDBRestApiClientOptions
1309+
{
1310+
ShouldPluralizeFromItemName = false,
1311+
};
1312+
servicesCollection.AddSingleton(restApiClientOptions);
1313+
```

0 commit comments

Comments
 (0)