GetVersion(string, int, int)
static
public static int GetVersion(string name, int minSupported, int maxSupported) Returns the version of the change
name which the running durable task follows, so code which changes a workflow keeps replaying the executions which started before the change. Parameters
namestring- The change's name within the running task, such as
"carrier-api". Every call with the same name in one execution returns the same version. Names don't contain$. minSupportedint- The oldest version which the calling code still supports. Version
0is the code before the change's first version. maxSupportedint- The newest version, which executions that reach the call for the first time record.
Returns
A version from
minSupported to maxSupported.Exceptions
System.ArgumentNullExceptionnameisnull.System.ArgumentExceptionnameis empty or contains$.System.ArgumentOutOfRangeExceptionminSupportedis negative, ormaxSupportedis less thanminSupported.Orleans.Durable.Tasks.DurableTaskAttemptCanceledException- The host canceled the attempt, for example because the execution recorded a version outside the supported range, which stalls it; the exception's inner exception is then a
DurableTaskVersionException. System.InvalidOperationException- The host can't record the version from the calling code, for example after
ConfigureAwait(false). System.NotSupportedException- The host doesn't support versions.
Examples
var version = DurableTask.GetVersion("carrier-api", minSupported: 0, maxSupported: 1); if (version >= 1) { await carrier.BookAsync(order).WithId("book"); } else { await legacyShipping.ShipAsync(order).WithId("ship"); }