Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<Project Sdk="Microsoft.NET.Sdk">
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="2.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PackageReference Include="Microsoft.Orleans.OrleansRuntime" Version="2.1.0" />
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Orleans;
using Orleans.Hosting;
namespace OrleansListDynamic
class Program
static async Task Main(string[] args)
var silo = new SiloHostBuilder()
await silo.StartAsync();
var client = silo.Services.GetRequiredService<IClusterClient>();
var grain = client.GetGrain<IMyGrain>(0);
var result = await grain.Echo(
new List<KeyValuePair<string, dynamic>>
new KeyValuePair<string, dynamic>("we", 1),
new KeyValuePair<string, dynamic>("have", Guid.NewGuid()),
new KeyValuePair<string, dynamic>("liftoff", DateTime.UtcNow),
Console.WriteLine($"Results ({result.Count}):");
foreach (var (key, value) in result)
Console.WriteLine($" * {key} = {value}");
public interface IMyGrain : IGrainWithIntegerKey
Task<T> Echo<T>(T value);
public class MyGrain : Grain, IMyGrain
public Task<T> Echo<T>(T value) => Task.FromResult(value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.