I want to implement an entity class in my Azure Durable Function. This should store a list of codes. Unfortunately, I get the following error when executing the Set method:
System.NullReferenceException: 'Object reference not set to an instance of an object.'.
Here is the code:
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class OrchestrationStatus
{
[JsonProperty("orchestrationStatus")]
public List<string> orchestrationStatus { get; set; } = new List<string>();
public Task Set(string code)
{
this.orchestrationStatus.Add(code);
return Task.CompletedTask;
}
public Task<List<string>> Get()
{
return Task.FromResult(this.orchestrationStatus);
}
[FunctionName(nameof(OrchestrationStatus))]
public static Task Run([EntityTrigger] IDurableEntityContext ctx)
=> ctx.DispatchAsync<OrchestrationStatus>();
}