private void DataPortal_Fetch(CriteriaEx criteria) { try { SessionCode = criteria.SessionCode; Childs = criteria.Childs; if (nHMng.UseDirectSQL) { Empresa.DoLOCK(Session()); IDataReader reader = nHMng.SQLNativeSelect(criteria.Query, Session()); if (reader.Read()) { CopyValues(reader); } if (Childs) { ContactoEmpresa.DoLOCK(Session()); string query = ContactoEmpresas.SELECT_BY_FIELD("OidEmpresa", this.Oid); reader = nHManager.Instance.SQLNativeSelect(query, Session()); _contactos = ContactoEmpresas.GetChildList(reader); } } } catch (Exception ex) { if (Transaction() != null) { Transaction().Rollback(); } iQExceptionHandler.TreatException(ex); } }
//private void DataPortal_Fetch(CriteriaEx criteria) //{ // try // { // SessionCode = criteria.SessionCode; // CopyValues((Empresa)(criteria.UniqueResult())); // Session().Lock(Session().Get<Empresa>(Oid), LockMode.UpgradeNoWait); // criteria = ContactoE.GetCriteria(Session()); // criteria.AddEq("OidEmpresa", this.Oid); // _contactos = ContactosE.GetChildList(criteria.List<ContactoE>()); // } // catch (NHibernate.ADOException) // { // if (Transaction() != null) Transaction().Rollback(); // throw new iQLockException(Resources.Messages.LOCK_ERROR); // } // catch (Exception ex) // { // if (Transaction() != null) Transaction().Rollback(); // iQExceptionHandler.TreatException(ex); // } //} private void DataPortal_Fetch(CriteriaEx criteria) { try { SessionCode = criteria.SessionCode; Childs = criteria.Childs; if (nHMng.UseDirectSQL) { Empresa.DoLOCK("COMMON", Session()); IDataReader reader = Empresa.DoSELECT("COMMON", Session(), criteria.Oid); if (reader.Read()) { CopyValues(reader); } if (Childs) { ContactoEmpresa.DoLOCK("COMMON", Session()); string query = ContactoEmpresas.SELECT_BY_FIELD("COMMON", "OidEmpresa", this.Oid); reader = nHManager.Instance.SQLNativeSelect(query, Session()); _contactos = ContactoEmpresas.GetChildList(reader); } } else { CopyValues((Empresa)(criteria.UniqueResult())); Session().Lock(Session().Get <Empresa>(Oid), LockMode.UpgradeNoWait); if (Childs) { criteria = ContactoEmpresa.GetCriteria(Session()); criteria.AddEq("OidEmpresa", this.Oid); _contactos = ContactoEmpresas.GetChildList(criteria.List <ContactoEmpresa>()); } } } catch (NHibernate.ADOException) { if (Transaction() != null) { Transaction().Rollback(); } throw new iQLockException(moleQule.Library.Resources.Messages.LOCK_ERROR); } catch (Exception ex) { if (Transaction() != null) { Transaction().Rollback(); } iQExceptionHandler.TreatException(ex); } }
// called to retrieve data from database protected override void Fetch(CriteriaEx criteria) { this.RaiseListChangedEvents = false; SessionCode = criteria.SessionCode; try { if (nHMng.UseDirectSQL) { ContactoEmpresa.DoLOCK("COMMON", Session()); IDataReader reader = nHManager.Instance.SQLNativeSelect(criteria.Query, Session());; IsReadOnly = false; while (reader.Read()) { this.AddItem(ContactoEmpresaInfo.Get(reader, Childs)); } IsReadOnly = true; } else { IList list = criteria.List(); if (list.Count > 0) { IsReadOnly = false; foreach (ContactoEmpresa item in list) { this.AddItem(item.GetInfo()); } IsReadOnly = true; } } } catch (Exception ex) { iQExceptionHandler.TreatException(ex); } this.RaiseListChangedEvents = true; }