Closed janslav closed 7 years ago
You can do this yourself:
public static class TransactionId
{
private static ShieldedLocal<Guid> _id = new ShieldedLocal<Guid>();
public static Guid Value
{
get
{
if (!_id.HasValue) _id.Value = Guid.NewGuid();
return _id.Value;
}
}
}
The ShieldedLocal Value lasts as long as the transaction run is in progress, and is visible from lambdas passed to SyncSideEffect and WhenCommitting.
Cool, looks like what I need, thanks :)
For logging/tracing purposes it might make sense to have some sort of id of the current transaction available. Currently there's just "IsInTransaction" boolean but no way of telling one transaction from the other. Could be conceivably constructed in user code by inserting some code around the InTransaction actions, but it won't be very reliable. Maybe make this an optional InTransaction() parameter?