public string GetKeyFrom(object anObject) { if (SessionFactoryKeyManger.Instance().ContainsKey(Thread.CurrentThread.ManagedThreadId)) { return(SessionFactoryKeyManger.Instance()[Thread.CurrentThread.ManagedThreadId]); } return(SessionFactoryAttribute.GetKeyFrom(anObject)); }
public void CanConfirmDatabaseMatchesMappings() { IDictionary <string, IClassMetadata> allClassMetadata = NHibernateSession.GetDefaultSessionFactory().GetAllClassMetadata(); string factoryKey = null; foreach (var entry in allClassMetadata) { if (entry.Key.Contains("Sde")) { factoryKey = SessionFactoryAttribute.GetKeyFrom(new SdeWorkOrderRepository()); } else { factoryKey = SessionFactoryAttribute.GetKeyFrom(new AgencyRepository()); } NHibernateSession.CurrentFor(factoryKey).CreateCriteria(entry.Value.GetMappedClass(EntityMode.Poco)) .SetMaxResults(0).List(); } }
/// <summary> /// Gets the session factory key. /// </summary> /// <param name="anObject">An object that may have the <see cref="SessionFactoryAttribute"/> applied.</param> /// <returns></returns> public string GetKeyFrom(object anObject) { return(SessionFactoryAttribute.GetKeyFrom(anObject)); }
public override Person SaveOrUpdate(Person entity) { NHibernateSession.CurrentFor(SessionFactoryAttribute.GetKeyFrom(new PersonRepository())).Save(entity); return(entity); }
public override Host SaveOrUpdate(Host entity) { NHibernateSession.CurrentFor(SessionFactoryAttribute.GetKeyFrom(new HostRepository())).Save(entity); return(entity); }