To answer my own question... I just spotted the UnitOfWorkManager.Begin() overload that allows us to pass in a UnitOfWorkOptions instance which could then be extended with my own properties...
However, it's important to note that the operation must mark itself with the [UnitOfWork] attribute set to IsDisabled = true.
public class ExtendedUnitOfWorkOptions : UnitOfWorkOptions
{
public ExtendedUnitOfWorkOptions()
{
UpdateLastModified = true;
}
public bool UpdateLastModified { get; set; }
}
Then in my DbContext I can override SetModificationAuditProperties() function:
protected override void SetModificationAuditProperties(DbEntityEntry entry, long? userId)
{
var isEnabled = true;
if (CurrentUnitOfWorkProvider != null && CurrentUnitOfWorkProvider.Current != null)
{
var uow = CurrentUnitOfWorkProvider.Current;
if (uow.Options is ExtendedUnitOfWorkOptions)
{
isEnabled = (uow.Options as ExtendedUnitOfWorkOptions).UpdateLastModified;
}
}
if (isEnabled)
{
base.SetModificationAuditProperties(entry, userId);
}
}
Which can be consumed within my special operation like:
[UnitOfWork(IsDisabled = true)]
public virtual async Task SignOffIncident(IdInput input)
{
using (var unitOfWork = UnitOfWorkManager.Begin(new ExtendedUnitOfWorkOptions() { UpdateLastModified = false }))
{
var incident = await _incidentManager.FindByIdAsync(input.Id);
incident.SignOffTime = Clock.Now;
incident.SignOffUserId = AbpSession.GetUserId();
await _incidentManager.UpdateAsync(incident);
unitOfWork.Complete();
}
}