// called to retrieve data from the database
        private void DataPortal_Fetch(CriteriaEx criteria)
        {
            try
            {
                SessionCode = criteria.SessionCode;

                Childs = criteria.Childs;

                if (nHMng.UseDirectSQL)
                {
                    Convocatoria_Curso.DoLOCK(Session());

                    IDataReader reader = Convocatoria_Curso.DoSELECT(AppContext.ActiveSchema.Code, Session(), criteria.Oid);

                    if (reader.Read())
                    {
                        _base.CopyValues(reader);
                    }

                    if (Childs)
                    {
                        Alumno_Convocatoria.DoLOCK(Session());

                        string query = Alumno_Convocatorias.SELECT_BY_CONVOCATORIA(this.Oid);
                        reader   = nHManager.Instance.SQLNativeSelect(query, Session());
                        _alumnos = Alumno_Convocatorias.GetChildList(reader);
                    }
                }
                else
                {
                    _base.Record.CopyValues((Convocatoria_CursoRecord)(criteria.UniqueResult()));

                    //Session().Lock(Session().Get<Convocatoria_CursoRecord>(Oid), LockMode.UpgradeNoWait);

                    if (Childs)
                    {
                        criteria = Alumno_Convocatoria.GetCriteria(Session());
                        criteria.AddEq("OidConvocatoria", this.Oid);
                        _alumnos = Alumno_Convocatorias.GetChildList(criteria.List <Alumno_Convocatoria>());
                    }
                }
            }
            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);
            }
        }
        private void Fetch(int session_code, IDataReader source)
        {
            try
            {
                _base.CopyValues(source);

                if (Childs)
                {
                    Alumno_Convocatoria.DoLOCK(Session(session_code));

                    string      query  = Alumno_Convocatorias.SELECT_BY_CONVOCATORIA(this.Oid);
                    IDataReader reader = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _alumnos = Alumno_Convocatorias.GetChildList(reader);
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
        private void Fetch(Convocatoria_Curso source)
        {
            try
            {
                SessionCode = source.SessionCode;

                _base.CopyValues(source);

                if (Childs)
                {
                    CriteriaEx criteria = Alumno_Convocatoria.GetCriteria(Session());
                    criteria.AddEq("OidConvocatoria", this.Oid);
                    _alumnos = Alumno_Convocatorias.GetChildList(criteria.List <Alumno_Convocatoria>());
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }