/// <summary> /// Translates a domain layer lock mode into an NHibernate lock mode via reflection. This is /// provided to facilitate developing the domain layer without a direct dependency on the /// NHibernate assembly. /// </summary> static LockMode ConvertFrom(Enums.LockMode lockMode) { switch (lockMode) { case Enums.LockMode.None: return(LockMode.None); case Enums.LockMode.Read: return(LockMode.Read); case Enums.LockMode.Upgrade: return(LockMode.Upgrade); case Enums.LockMode.UpgradeNoWait: return(LockMode.UpgradeNoWait); case Enums.LockMode.Write: return(LockMode.Write); default: throw new ArgumentOutOfRangeException(nameof(lockMode), lockMode, "The provided lock mode , '" + lockMode + ",' could not be translated into an NHibernate.LockMode. " + "This is probably because NHibernate was updated and now has different lock modes which are out of synch " + "with the lock modes maintained in the domain layer."); } }
public virtual T Load(IdT id, Enums.LockMode lockMode = Enums.LockMode.None) { using (var wu = SessionManager.WorkUnitFor(this, DbWorkUnitType.Read)) { return(wu.Session.Load <T>(id, ConvertFrom(lockMode))); } }
protected static LockMode ConvertFrom(Enums.LockMode lockMode) { var translatedLockMode = typeof(LockMode).GetField( lockMode.ToString(), BindingFlags.Public | BindingFlags.Static); return((LockMode)translatedLockMode.GetValue(null)); }
/// <summary> /// Translates a domain layer lock mode into an NHibernate lock mode via reflection. This is /// provided to facilitate developing the domain layer without a direct dependency on the /// NHibernate assembly. /// </summary> private static LockMode ConvertFrom(Enums.LockMode lockMode) { FieldInfo translatedLockMode = typeof(LockMode).GetField(lockMode.ToString(), BindingFlags.Public | BindingFlags.Static); Check.Ensure(translatedLockMode != null, "The provided lock mode , '" + lockMode + ",' " + "could not be translated into an NHibernate.LockMode. This is probably because " + "NHibernate was updated and now has different lock modes which are out of synch " + "with the lock modes maintained in the domain layer."); return((LockMode)translatedLockMode.GetValue(null)); }
public override T Load(int id, Enums.LockMode lockMode = Enums.LockMode.None) { var entity = base.Load(id, lockMode); if (ComponentsLoadLevel >= ComponentsLoadLevel.Single && entity != null) { entity.Settings = settingsService.GetFor(entity); } return(entity); }
public override T Load(int id, Enums.LockMode lockMode = Enums.LockMode.None) { var entity = base.Load(id, lockMode); if (entity != null && ComponentsLoadLevel >= ComponentsLoadLevel.Single) { entity.Metrics = metricsService.GetFor(entity); } return(entity); }
/// <summary> /// Translates a domain layer lock mode into an NHibernate lock mode via reflection. This is /// provided to facilitate developing the domain layer without a direct dependency on the /// NHibernate assembly. /// </summary> protected LockMode ConvertFrom(Enums.LockMode lockMode) { FieldInfo translatedLockMode = typeof(LockMode).GetField(lockMode.ToString(), BindingFlags.Public | BindingFlags.Static); if (translatedLockMode == null) { throw new InvalidCastException( "The provided lock mode , '" + lockMode + ",' " + "could not be translated into an NHibernate.LockMode. This is probably because " + "NHibernate was updated and now has different lock modes which are out of synch " + "with the lock modes maintained in the domain layer."); } return((LockMode)translatedLockMode.GetValue(null)); }
public virtual T Load(IdT id, Enums.LockMode lockMode) { return(Session.Load <T>(id, ConvertFrom(lockMode))); }
public virtual T Load(TId id, Enums.LockMode lockMode) { return(this.Session.Load <T>(id, ConvertFrom(lockMode))); }
/// <summary> /// Returns null if a row is not found matching the provided Id. /// </summary> /// <param name="id"></param> /// <param name="lockMode"></param> /// <returns></returns> public virtual T Get(TId id, Enums.LockMode lockMode) { return(Session.Get <T>(id, ConvertFrom(lockMode))); }
/// <inheritdoc /> public Task <T> LoadAsync( TId id, Enums.LockMode lockMode, CancellationToken cancellationToken = default(CancellationToken)) { return(Session.LoadAsync <T>(id, ConvertFrom(lockMode), cancellationToken)); }