Skip to content

Commit 7bcaf07

Browse files
committed
[ksqlDb.RestApi.Client]: added AsStruct model builder example to samples
1 parent 55fc3b9 commit 7bcaf07

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Samples/ksqlDB.RestApi.Client.Sample/ModelBuilders/PaymentModelBuilder.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ public async Task InitModelAndCreateStreamAsync(CancellationToken cancellationTo
3434
.Property(c => c.Header)
3535
.WithHeader(header);
3636

37+
modelBuilder.Entity<Record>()
38+
.Property(b => b.Headers)
39+
.AsStruct()
40+
.WithHeaders();
41+
42+
modelBuilder.Entity<KeyValuePair>()
43+
.Property(c => c.Key)
44+
.HasColumnName(nameof(KeyValuePair.Key).ToUpper());
45+
46+
modelBuilder.Entity<KeyValuePair>()
47+
.Property(c => c.Value)
48+
.HasColumnName(nameof(KeyValuePair.Value).ToUpper());
49+
3750
var restApiProvider = ConfigureRestApiClientWithServicesCollection(new ServiceCollection(), modelBuilder);
3851

3952
var entityCreationMetadata = new EntityCreationMetadata(kafkaTopic: nameof(Payment), partitions: 1);
@@ -94,3 +107,14 @@ record PocoWithHeader
94107
{
95108
public byte[] Header { get; init; } = null!;
96109
}
110+
111+
record KeyValuePair
112+
{
113+
public string Key { get; set; } = null!;
114+
public byte[] Value { get; set; } = null!;
115+
}
116+
117+
record Record
118+
{
119+
public KeyValuePair[] Headers { get; init; } = null!;
120+
}

Samples/ksqlDB.RestApi.Client.Sample/ksqlDB.RestApi.Client.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="ksqlDb.RestApi.Client" Version="6.2.0" />
12+
<PackageReference Include="ksqlDb.RestApi.Client" Version="6.3.0-rc.1" />
1313
<!-- <ProjectReference Include="..\..\ksqlDb.RestApi.Client\ksqlDb.RestApi.Client.csproj" /> -->
1414
<!-- <PackageReference Include="ksqlDb.RestApi.Client.ProtoBuf" Version="4.0.0" /> -->
1515
<ProjectReference Include="..\..\ksqlDb.RestApi.Client.ProtoBuf\ksqlDb.RestApi.Client.ProtoBuf.csproj" />

0 commit comments

Comments
 (0)