diff --git a/bindings/csharp/sdk/batch/batch.csproj b/bindings/csharp/sdk/batch/batch.csproj
index 492bab613..1d43dc767 100644
--- a/bindings/csharp/sdk/batch/batch.csproj
+++ b/bindings/csharp/sdk/batch/batch.csproj
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file
diff --git a/bindings/csharp/sdk/batch/program.cs b/bindings/csharp/sdk/batch/program.cs
index 354d95410..75bf9fd26 100644
--- a/bindings/csharp/sdk/batch/program.cs
+++ b/bindings/csharp/sdk/batch/program.cs
@@ -31,6 +31,8 @@ limitations under the License.
options.SupportedCultures = [invariantCulture];
});
+builder.Services.AddDaprClient();
+
var app = builder.Build();
if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); }
@@ -38,13 +40,12 @@ limitations under the License.
app.UseRequestLocalization();
// Triggered by Dapr input binding
-app.MapPost("/" + cronBindingName, async () =>
+app.MapPost("/" + cronBindingName, async (DaprClient client) =>
{
Console.WriteLine("Processing batch..");
string jsonFile = File.ReadAllText("../../../orders.json");
var ordersArray = JsonSerializer.Deserialize(jsonFile);
- using var client = new DaprClientBuilder().Build();
foreach (Order ord in ordersArray?.orders ?? new Order[] { })
{
var sqlText = $"insert into orders (orderid, customer, price) values ({ord.OrderId}, '{ord.Customer}', {ord.Price});";
@@ -65,5 +66,5 @@ limitations under the License.
await app.RunAsync();
-public record Order([property: JsonPropertyName("orderid")] int OrderId, [property: JsonPropertyName("customer")] string Customer, [property: JsonPropertyName("price")] float Price);
-public record Orders([property: JsonPropertyName("orders")] Order[] orders);
\ No newline at end of file
+public sealed record Order([property: JsonPropertyName("orderid")] int OrderId, [property: JsonPropertyName("customer")] string Customer, [property: JsonPropertyName("price")] float Price);
+public sealed record Orders([property: JsonPropertyName("orders")] Order[] orders);
\ No newline at end of file