Мне нужно обновить столбец в OnFlushDirty
, который реализован NHibernate - IInterceptor
.
Я использую свойство, которое инициализируется в методе before-save, но в Перехватчике свойство в сущностивсе еще пусто(поскольку он не сопоставлен - нет необходимости отображать это свойство, необходимое только для Inercerptor
использования)
вот код:
public override bool OnFlushDirty(object entity,
object id,
object[] currentState,
object[] previousState,
string[] propertyNames,
IType[] types)
{
var index = propertyNames.IndexOf("LastUpdateDate");
if (index >= 0 && entity is ISessionPerUser)
{
currentState[index] = DateTime.Now;
var lastUpdateUserIdIndex = propertyNames.IndexOf("LastUpdateUserId");
if(index >= 0))
{
currentState[lastUpdateUserIdIndex] = (entity as ISessionPerUser).RequestUserId;
}
return true;
}
return base.OnFlushDirty(entity, id, currentState, previousState, propertyNames, types);
}
У кого-нибудь есть решение?