Skip to content

Commit

Permalink
Added example for retrieving bulk deserialized items matching PR #1173
Browse files Browse the repository at this point in the history
…in dotnet-sdk repo.

Signed-off-by: Whit Waldo <[email protected]>
  • Loading branch information
WhitWaldo committed Oct 23, 2023
1 parent 3cc2f02 commit 661a1ed
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,33 @@ To launch a Dapr sidecar for the above example application, run a command simila
dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-grpc-port 60001 dotnet run
```

The above example will return a `BulkStateItem` with the serialized format of the value you saved to state. If you would prefer that the value be deserialized by the SDK across each of your bulk response items, you can instead use the following:

```csharp
//dependencies
using Dapr.Client;
//code
namespace EventService
{
class Program
{
static async Task Main(string[] args)
{
string DAPR_STORE_NAME = "statestore";
//Using Dapr SDK to retrieve multiple states
using var client = new DaprClientBuilder().Build();
IReadOnlyList<BulkStateItem<Widget>> mulitpleStateResult = await client.GetBulkStateAsync<Widget>(DAPR_STORE_NAME, new List<string> { "widget_1", "widget_2" }, parallelism: 1);
}
}
class Widget
{
string Size { get; set; }
string Color { get; set; }
}
}
```

{{% /codetab %}}

{{% codetab %}}
Expand Down

0 comments on commit 661a1ed

Please sign in to comment.