/// <summary> /// Compare with oid fields /// </summary> /// <param name="instance1">Instance 1</param> /// <param name="instance2">Instance 2</param> /// <returns>0 if equals, -1 if instance1 is minor, 1 if instance2 is mayor</returns> public override int CompareUnionOID(ONInstance instance1, ONInstance instance2) { // Null Management if ((instance1 == null) && (instance2 == null)) { return(0); } else if (instance1 == null) { return(-1); } else if (instance2 == null) { return(1); } PasajeroInstance lInstance1 = instance1 as PasajeroInstance; PasajeroInstance lInstance2 = instance2 as PasajeroInstance; int lCompare = 0; // id_Pasajero(Asc) lCompare = lInstance1.Id_PasajeroAttr.CompareTo(lInstance2.Id_PasajeroAttr); if (lCompare != 0) { return(lCompare); } return(0); }
public override bool FilterInMemory(ONInstance instance) { PasajeroInstance lInstance = instance as PasajeroInstance; // SQL Optimized return(true); }
///<summary> This method adds the order criteria to the SQL statement </summary> ///<param name = "onSql"> This parameter represents the SQL component </param> ///<param name = "comparer"> This parameter has all the information refering to the order criteria to add to SQL statement</param> /// <param name="startRowOid">This parameter has the OID necessary to start the search</param> /// <param name="blockSize">This parameter represents the number of instances to be returned</param> protected override void AddOrderCriteria(ONSqlSelect onSql, ONOrderCriteria comparer, ONOid startRowOid, int blockSize, ONPath initialPath) { //Initilizate StartRow PasajeroInstance lInstance = null; if (startRowOid != null) { lInstance = new PasajeroInstance(OnContext); lInstance.Oid = startRowOid as PasajeroOid; } //Default OrderCriteria if (comparer == null) { string lAlias = onSql.GetAlias("Pasajero", initialPath); if (lInstance != null) { onSql.AddOrderBy(lAlias, CtesBD.FLD_PASAJERO_ID_PASAJERO, OrderByTypeEnumerator.Asc, lInstance.Oid.Id_PasajeroAttr); } else { onSql.AddOrderBy(lAlias, CtesBD.FLD_PASAJERO_ID_PASAJERO, OrderByTypeEnumerator.Asc, null); } return; } //Add OrderCriteria bool lUseStartRow = (!comparer.InMemory); foreach (ONOrderCriteriaItem lOrderCriteriaItem in comparer.OrderCriteriaSqlItem) { ONPath lPath = new ONPath(lOrderCriteriaItem.OnPath); if ((lInstance != null) && (lUseStartRow)) { ONSimpleType lAttrStartRow = null; if (lPath.Path == "") { lAttrStartRow = lInstance[lOrderCriteriaItem.Attribute] as ONSimpleType; } else { ONCollection lCollection = (lInstance[lPath.Path] as ONCollection); if ((lCollection != null) && (lCollection.Count > 0)) { lAttrStartRow = lCollection[0][lOrderCriteriaItem.Attribute] as ONSimpleType; } } onSql.AddOrderBy(PasajeroData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, lAttrStartRow); lUseStartRow = (lAttrStartRow != null); } else { onSql.AddOrderBy(PasajeroData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, null); } } return; }
///<summary> /// This method builds the SQL statment to delete the instance in database ///</summary> ///<param name = instance> ///This parameter represents the instance to be deleted in the database ///</param> public override void UpdateDeleted(ONInstance instance) { PasajeroInstance lInstance = instance as PasajeroInstance; ONSqlDelete lOnSql = new ONSqlDelete(); lOnSql.AddFrom(CtesBD.TBL_PASAJERO); lOnSql.AddWhere(CtesBD.FLD_PASAJERO_ID_PASAJERO, lInstance.Oid.Id_PasajeroAttr); Execute(lOnSql); }
public PasajeroInstance Create_instanceServ(PasajeroAeronaveOid p_agrPasajeroAeronaveArg, ONInt p_atrid_PasajeroArg, ONText p_atrNombreArg) { // Create new context using (ONServiceContext lOnContext = new ONServiceContext(OnContext)) { // Call Executive PasajeroExecutive lExecutive = new PasajeroExecutive(); lExecutive.OnContext = lOnContext; lExecutive.Instance = Instance; Instance = lExecutive.Create_instanceServ(p_agrPasajeroAeronaveArg, p_atrid_PasajeroArg, p_atrNombreArg); } return(Instance); }
public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext) { string lAlias = onSql.CreateAlias(CtesBD.TBL_PASAJERO, onPath, "Pasajero"); ONDisplaySet lSourceDS = null; if (displaySet != null) { lSourceDS = new ONDisplaySet(displaySet); displaySet.Clear(); } if (displaySet == null) { onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_ID_PASAJERO + ", " + lAlias + "." + CtesBD.FLD_PASAJERO_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_PASAJERO_FUM); } else { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_PASAJERO_ID_PASAJERO)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_ID_PASAJERO); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_PASAJERO_ESTADOOBJ)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_ESTADOOBJ); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_PASAJERO_FUM)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_FUM); if (lSourceDS.Contains(CtesBD.FLD_PASAJERO_NOMBRE)) { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_PASAJERO_NOMBRE)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_NOMBRE); } } // Related attributes if (displaySet != null) { foreach (ONDisplaySetItem lDisplaySetItem in lSourceDS) { if ((lDisplaySetItem.Path.IndexOf(".") > 0) && (lDisplaySetItem.InData) && (!lDisplaySetItem.HasHV)) { displaySet.Add(lDisplaySetItem); string lPath = lDisplaySetItem.Path.Substring(0, lDisplaySetItem.Path.LastIndexOf(".")); string lFacetName = PasajeroInstance.GetTargetClass(onContext, typeof(PasajeroInstance), new ONPath(lDisplaySetItem.Path)); onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(PasajeroInstance), new ONPath(lDisplaySetItem.Path))); } } } return(lAlias); }
/// <summary>This method builds the SQL statement to insert the instance in database</summary> /// <param name="instance">This parameter represents the instance to be inserted in the database</param> public override void UpdateAdded(ONInstance instance) { PasajeroInstance lInstance = instance as PasajeroInstance; ONSqlInsert lOnSql = new ONSqlInsert(); lOnSql.AddInto(CtesBD.TBL_PASAJERO); // Field 'id_Pasajero' lOnSql.AddValue(CtesBD.FLD_PASAJERO_ID_PASAJERO, lInstance.Oid.Id_PasajeroAttr); lOnSql.AddValue(CtesBD.FLD_PASAJERO_ESTADOOBJ, lInstance.StateObj); lOnSql.AddValue(CtesBD.FLD_PASAJERO_FUM, new ONDateTime(DateTime.Now)); // Field 'Nombre' lOnSql.AddValue(CtesBD.FLD_PASAJERO_NOMBRE, lInstance.NombreAttr); Execute(lOnSql); }
/// <summary> /// Load the data retrieved from the Data Base to components of the application /// </summary> /// <param name="onContext">This parameter has the current context</param> /// <param name="columns">This parameter has the data collected from the database</param> /// <param name="index">This parameter has the position of the first data to fix in the application</param> public static PasajeroInstance LoadFacet(ONContext onContext, ONDisplaySet displaySet, object[] columns, ref int index) { PasajeroInstance lInstance = new PasajeroInstance(onContext); lInstance.Oid = new PasajeroOid(); // Field 'id_Pasajero' lInstance.Oid.Id_PasajeroAttr = new ONInt(Convert.ToInt32(columns[index++])); lInstance.StateObj = new ONString(((string)columns[index++]).TrimEnd()); lInstance.Lmd = new ONDateTime((DateTime)columns[index++]); if ((displaySet != null) && (displaySet.Contains("Nombre"))) { lInstance.NombreAttr = new ONText((string)columns[index++]); } lInstance.Modified = false; return(lInstance); }
protected override ONInstance InhGetInstance(ONContext onContext, ONFilterList onFilterList) { // Add oid filter to the list ONFilterList lOnFilterList = new ONFilterList(onFilterList); lOnFilterList.Add("QueryByOid", new QueryByOidFilter(this)); // Search Instance ONInstance lInstance = new PasajeroInstance(onContext); lInstance.Oid = this; lInstance = lInstance.Find(lOnFilterList); if (lInstance == null) { lInstance = new PasajeroInstance(onContext); } return(lInstance); }
internal PasajeroInstance Create_instanceServ(PasajeroAeronaveOid p_agrPasajeroAeronaveArg, ONInt p_atrid_PasajeroArg, ONText p_atrNombreArg) { if (Instance != null) { ONFilterList onfilt = new ONFilterList(); onfilt.Add("QueryByOid", new QueryByOidFilter(Instance.Oid)); Instance.Find(onfilt); } // Execute service PasajeroAction lAction = new PasajeroAction(OnContext); lAction.Instance = new PasajeroInstance(OnContext); Instance = lAction.Create_instanceServ(p_agrPasajeroAeronaveArg, p_atrid_PasajeroArg, p_atrNombreArg); OnContext.OperationStack.Pop(); OnContext.OperationStack.Push(Instance); return(Instance); }
/// <summary>This method builds the SQL statement to edit the instance in database</summary> /// <param name="instance">This parameter represents the instance to be modified in the database</param> public override void UpdateEdited(ONInstance instance) { PasajeroInstance lInstance = instance as PasajeroInstance; ONSqlUpdate lOnSql = new ONSqlUpdate(); lOnSql.AddUpdate(CtesBD.TBL_PASAJERO); // Field 'id_Pasajero' // Update not needed (OID) lOnSql.AddSet(CtesBD.FLD_PASAJERO_ESTADOOBJ, lInstance.StateObj); lOnSql.AddSet(CtesBD.FLD_PASAJERO_FUM, new ONDateTime(DateTime.Now)); // Field 'Nombre' if (lInstance.NombreAttrModified) { lOnSql.AddSet(CtesBD.FLD_PASAJERO_NOMBRE, lInstance.NombreAttr); } lOnSql.AddWhere(CtesBD.FLD_PASAJERO_ID_PASAJERO, lInstance.Oid.Id_PasajeroAttr); Execute(lOnSql); }
/// <summary> /// Converts the instances returned by a query in XML format in order to put it in XML message response /// </summary> /// <param name="agentOid">OID with the agent connected to the system</param> /// <param name="xmlWriter">This parameter has the response message XML</param> /// <param name="val">Instances that fullfils with the query request</param> /// <param name="startRowOID">OID necessary to start the search</param> /// <param name="blockSize">Represents the number of instances to be returned</param> /// <param name="displaySet">Attributes to be returned in the response</param> /// <param name="dtdVersion">Version of DTD that follows the XML message</param> public override void ONQuery2XML(ONOid agentOid, XmlWriter xmlWriter, ONCollection val, ONOid startRowOID, int blockSize, ONDisplaySet displaySet, double dtdVersion) { xmlWriter.WriteStartElement("Head"); xmlWriter.WriteStartElement("Head.OID"); xmlWriter.WriteAttributeString("Class", "Pasajero"); xmlWriter.WriteStartElement("Head.OID.Field"); xmlWriter.WriteAttributeString("Name", "id_Pasajero"); xmlWriter.WriteAttributeString("Type", "autonumeric"); xmlWriter.WriteEndElement(); // Head.OID.Field xmlWriter.WriteEndElement(); // Head.OID xmlWriter.WriteStartElement("Head.Cols"); foreach (ONDisplaySetItem lDisplaySetItem in displaySet) { xmlWriter.WriteStartElement("Head.Col"); xmlWriter.WriteAttributeString("Name", lDisplaySetItem.Path); string lType = ONInstance.GetTypeOfAttribute(typeof(PasajeroInstance), new ONPath(lDisplaySetItem.Path)); if (lType == "") { lType = "string"; } xmlWriter.WriteAttributeString("Type", lType); xmlWriter.WriteEndElement(); // Head.Col } xmlWriter.WriteEndElement(); // Head.Cols xmlWriter.WriteEndElement(); // Head // Search StartRow int i = 0; if (startRowOID != null) { i = val.IndexOf(startRowOID) + 1; } // Instance count int lInstances = 0; int lNumInstances = 0; string lLastBlock = "True"; if (i >= 0) { lNumInstances = val.Count - i; if ((blockSize > 0) && (lNumInstances > blockSize)) { lNumInstances = blockSize; lLastBlock = "False"; } } xmlWriter.WriteStartElement("Data"); xmlWriter.WriteAttributeString("Rows", lNumInstances.ToString()); xmlWriter.WriteAttributeString("LastBlock", lLastBlock); xmlWriter.WriteAttributeString("TotalRows", val.totalNumInstances.ToString()); while ((lInstances++ < lNumInstances) && (i < val.Count)) { PasajeroInstance lInstance = val[i++] as PasajeroInstance; xmlWriter.WriteStartElement("R"); ONXmlAutonumeric.ON2XML(xmlWriter, lInstance.Oid.Id_PasajeroAttr, dtdVersion, ONXml.XMLTAG_O); foreach (ONDisplaySetItem lDisplaySetItem in displaySet) { if (lDisplaySetItem.Visibility == VisibilityState.NotChecked) { if (ONInstance.IsVisible(lInstance.GetType(), lDisplaySetItem.Path, lInstance.OnContext)) { lDisplaySetItem.Visibility = VisibilityState.Visible; } else { lDisplaySetItem.Visibility = VisibilityState.NotVisible; } } if (lDisplaySetItem.Visibility == VisibilityState.NotVisible) // No Visibility { xmlWriter.WriteElementString("V", null); } else { ONSimpleType lAttribute; if (lDisplaySetItem.HasHV) { lAttribute = lInstance.DisplaysetItemValue(lDisplaySetItem.Path); } else { lAttribute = lInstance[lDisplaySetItem.Path] as ONSimpleType; } if (lAttribute is ONInt) { ONXmlInt.ON2XML(xmlWriter, lAttribute as ONInt, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONString) { ONXmlString.ON2XML(xmlWriter, lAttribute as ONString, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONBlob) { ONXmlBlob.ON2XML(xmlWriter, lAttribute as ONBlob, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONBool) { ONXmlBool.ON2XML(xmlWriter, lAttribute as ONBool, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONReal) { ONXmlReal.ON2XML(xmlWriter, lAttribute as ONReal, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONInt) { ONXmlAutonumeric.ON2XML(xmlWriter, lAttribute as ONInt, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONDate) { ONXmlDate.ON2XML(xmlWriter, lAttribute as ONDate, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONDateTime) { ONXmlDateTime.ON2XML(xmlWriter, lAttribute as ONDateTime, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONTime) { ONXmlTime.ON2XML(xmlWriter, lAttribute as ONTime, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONNat) { ONXmlNat.ON2XML(xmlWriter, lAttribute as ONNat, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONText) { ONXmlText.ON2XML(xmlWriter, lAttribute as ONText, dtdVersion, ONXml.XMLTAG_V); } else if (lAttribute is ONString) { ONXmlPassword.ON2XML(xmlWriter, lAttribute as ONString, dtdVersion, ONXml.XMLTAG_V); } } } xmlWriter.WriteEndElement(); // R } xmlWriter.WriteEndElement(); // Data }
public void Create_instanceServ(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, XmlWriter xmlWriter, double dtdVersion, string clientName) { // Process the service arguments ONServiceInfo lSInfo = new ONServiceInfo("Clas_1348178542592658Ser_1_Alias", PasajeroClassText.Create_instanceServiceAlias, "Clas_1348178542592658_Alias", PasajeroClassText.ClassAlias); lSInfo.AddOIDArgument("p_agrPasajeroAeronave", false, "PasajeroAeronave", "Clas_1348178542592658Ser_1Arg_4_Alias", PasajeroClassText.Create_instance_P_agrPasajeroAeronaveArgumentAlias); lSInfo.AddDataValuedArgument("p_atrid_Pasajero", false, DataTypeEnumerator.Autonumeric, 0, "Clas_1348178542592658Ser_1Arg_1_Alias", PasajeroClassText.Create_instance_P_atrid_PasajeroArgumentAlias); lSInfo.AddDataValuedArgument("p_atrNombre", false, DataTypeEnumerator.Text, 0, "Clas_1348178542592658Ser_1Arg_2_Alias", PasajeroClassText.Create_instance_P_atrNombreArgumentAlias); try { lSInfo.XML2ON(xmlReader, dtdVersion, true); } catch (Exception e) { throw new ONServiceArgumentsException(e, "Clas_1348178542592658_Alias", PasajeroClassText.ClassAlias, "Clas_1348178542592658Ser_1_Alias", PasajeroClassText.Create_instanceServiceAlias); } PasajeroAeronaveOid lP_agrPasajeroAeronaveArg = (PasajeroAeronaveOid)((ONArgumentInfo)lSInfo.mArgumentList["p_agrPasajeroAeronave"]).Value; ONInt lP_atrid_PasajeroArg = (ONInt)((ONArgumentInfo)lSInfo.mArgumentList["p_atrid_Pasajero"]).Value; ONText lP_atrNombreArg = (ONText)((ONArgumentInfo)lSInfo.mArgumentList["p_atrNombre"]).Value; // Create Context ONServiceContext lOnContext = new ONServiceContext(); lOnContext.OidAgent = agentOid; // Execute Service PasajeroInstance lInstance = null; try { ONFilterList lFilterList = new ONFilterList(); PasajeroAeronaveInstance lp_agrPasajeroAeronaveInstance = new PasajeroAeronaveInstance(lOnContext); if (lP_agrPasajeroAeronaveArg != null) { lFilterList = new ONFilterList(); lFilterList.Add("HorizontalVisibility", new PasajeroAeronaveHorizontalVisibility()); lp_agrPasajeroAeronaveInstance = lP_agrPasajeroAeronaveArg.GetInstance(lOnContext, lFilterList); if (lp_agrPasajeroAeronaveInstance == null) { throw new ONInstanceNotExistException(null, "Clas_1348178542592177_Alias", PasajeroAeronaveClassText.ClassAlias); } } using (PasajeroServer lServer = new PasajeroServer(lOnContext, null)) { lServer.Create_instanceServ(lP_agrPasajeroAeronaveArg, lP_atrid_PasajeroArg, lP_atrNombreArg); lInstance = lServer.Instance; } ticket = lOnContext.GetTicket(dtdVersion, clientName); } catch (SecurityException) { throw new ONAccessAgentValidationException(null); } catch { throw; } // Write Oid if (dtdVersion >= 3.1) { if (lInstance != null) { ON2XML(xmlWriter, lInstance.Oid, dtdVersion, ONXml.XMLTAG_OIDFIELD); } } // Write Outbound Arguments xmlWriter.WriteStartElement("Arguments"); // Write Outbound Arguments xmlWriter.WriteEndElement(); // Arguments }
/// <summary> /// Constructor /// </summary> /// <param name="onContext">This parameter has the current context</param> /// <param name="instance">This parameter has the instance that exectues the service</param> public PasajeroServer(ONServiceContext onContext, PasajeroInstance instance) : base(onContext, instance, "Pasajero") { }
/// <summary> /// Executes the SQL statment over the Data Base connected /// </summary> /// <param name="onSql">This parameter has the current SQL statment</param> /// <param name="onFilterList">List of filters to check</param> /// <param name="comparer">This parameter has all the information refering to the order criteria to add to SQL statment</param> /// <param name="startRowOid">This parameter has the OID necessary to start the search</param> /// <param name="blockSize">This parameter represents the number of instances to be returned</param> public override ONCollection ExecuteSql(ONSql onSql, ONFilterList onFilterList, ONDisplaySet displaySet, ONOrderCriteria orderCriteria, ONOid startRowOid, int blockSize) { PasajeroCollection lQuery = null; bool lWithStartRow = (startRowOid != null).TypedValue; long lCount = -1; if (!lWithStartRow) { lCount = 0; } IDataReader lDataReader = null; ONSQLConnection lOnSQLConnection = null; try { lDataReader = Execute(onSql) as IDataReader; PasajeroInstance lInstance = null; PasajeroInstance lAntInstance = null; if (lDataReader != null) { object[] lColumns; if (displaySet == null) { lColumns = new object[3]; } else { lColumns = new object[displaySet.ElementsInData]; } lQuery = new PasajeroCollection(OnContext); bool lFoundStartRow = false; while (lDataReader.Read()) { lAntInstance = lInstance; // Read Columns lDataReader.GetValues(lColumns); // Read Instance int lIndex = 0; lInstance = LoadFacet(OnContext, displaySet, lColumns, ref lIndex); // Read related attributes if (displaySet != null) { LoadRelated(OnContext, displaySet, lColumns, lIndex, lInstance); } if (lCount >= 0) // Add the load instance { if ((onFilterList == null) || (!onFilterList.InMemory)) { // Add to the Instance list lQuery.Add(lInstance); lCount++; } else { ONSQLConnection lSQLConnectionOld = (ONSQLConnection)lInstance.OnContext.SqlConnection; // Set another connection because it is imposible to use // the same connection that is used in the DataReader if (lOnSQLConnection == null) { lOnSQLConnection = GetConnection(); } lInstance.OnContext.SqlConnection = lOnSQLConnection; if (onFilterList.FilterInMemory(lInstance)) { // Add to the Instance list lQuery.Add(lInstance); lCount++; } lInstance.OnContext.SqlConnection = lSQLConnectionOld; } } else { if ((orderCriteria != null) && (orderCriteria.InMemory)) // Need to load for ordering in memory after loading { if (lAntInstance != null) { // Set another connection because it is imposible to use // the same connection that is used in the DataReader ONSQLConnection lOnSQLConnectionOld = lInstance.OnContext.SqlConnection as ONSQLConnection; if (lOnSQLConnection == null) { lOnSQLConnection = GetConnection(); } lInstance.OnContext.SqlConnection = lOnSQLConnection; int lCompare = orderCriteria.CompareSql(lInstance, lAntInstance); if (lCompare != 0) { if (lFoundStartRow) { lCount = 1; } else { lQuery.Clear(); } } // Restores the old connection lInstance.OnContext.SqlConnection = lOnSQLConnectionOld; } if ((onFilterList == null) || (!onFilterList.InMemory)) { // Add to the Instance list lQuery.Add(lInstance); } else { ONSQLConnection lSQLConnectionOld = (ONSQLConnection)lInstance.OnContext.SqlConnection; // Set another connection because it is imposible to use // the same connection that is used in the DataReader if (lOnSQLConnection == null) { lOnSQLConnection = GetConnection(); } lInstance.OnContext.SqlConnection = lOnSQLConnection; if (onFilterList.FilterInMemory(lInstance)) { // Add to the Instance list lQuery.Add(lInstance); } else { lCount--; } lInstance.OnContext.SqlConnection = lSQLConnectionOld; } if (lInstance.Oid.Equals(startRowOid)) { lFoundStartRow = true; } } else if (lInstance.Oid.Equals(startRowOid)) // Search the start row { lCount = 0; } } // Stop loading if ((blockSize != 0) && (lCount > blockSize)) { if (orderCriteria == null) { break; } else { // Set another connection because it is imposible to use // the same connection that is used in the DataReader ONSQLConnection lOnSQLConnectionOld = lInstance.OnContext.SqlConnection as ONSQLConnection; if (lOnSQLConnection == null) { lOnSQLConnection = GetConnection(); } lInstance.OnContext.SqlConnection = lOnSQLConnection; int lCompare = orderCriteria.CompareSql(lInstance, lAntInstance); // Restores the old connection lInstance.OnContext.SqlConnection = lOnSQLConnectionOld; if (lCompare > 0) { break; } } } } } } catch (Exception e) { string ltraceItem = "Method: ExecuteSql, Component: PasajeroData"; if (e is ONSystemException) { ONSystemException lException = e as ONSystemException; lException.addTraceInformation(ltraceItem); throw lException; } throw new ONSystemException(e, ltraceItem); } finally { if (lOnSQLConnection != null) { ONDBData.CloseConnection(lOnSQLConnection); } if (lDataReader != null) { if (mSqlCommand != null) { mSqlCommand.Cancel(); } lDataReader.Close(); } Close(); if ((onFilterList != null) && (onFilterList.InMemory) && !lWithStartRow && (lCount <= blockSize)) { lQuery.totalNumInstances = lQuery.Count; } } return(lQuery); }