Skip to content

Instantly share code, notes, and snippets.

@cgillum
Last active May 18, 2019 01:23
Show Gist options
  • Save cgillum/aaa9dbd975a5084edebc06741c153427 to your computer and use it in GitHub Desktop.
Save cgillum/aaa9dbd975a5084edebc06741c153427 to your computer and use it in GitHub Desktop.
Example of "counter" entity in Durable Functions.
public static async Task Counter(
[EntityTrigger] IDurableEntityContext ctx)
{
int currentValue = ctx.GetState<int>();
switch (ctx.OperationName)
{
case "add":
int amount = ctx.GetInput<int>();
currentValue += amount;
break;
case "reset":
currentValue = 0;
break;
case "get":
ctx.Return(currentValue);
return;
}
ctx.SetState(currentValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment