/// <summary>Default Constructor</summary>
 public NaveNodrizaInstance(ONContext onContext)
     : base(onContext, "NaveNodriza", "Clas_1347649273856884_Alias")
 {
     Oid = new NaveNodrizaOid();
     Nombre_NaveNodrizaAttr = ONString.Null;
     StateObjAttrTemp = null;
 }
        public override void Copy(object oid)
        {
            NaveNodrizaOid lOid = oid as NaveNodrizaOid;

            if (lOid != null)
            {
                Id_NaveNodrizaAttr = new ONInt(lOid.Id_NaveNodrizaAttr);
            }
            base.Copy(oid);
        }
 public NaveNodrizaOid(NaveNodrizaOid oid) : base("NaveNodriza")
 {
     if (oid != null)
     {
         Id_NaveNodrizaAttr = new ONInt(oid.Id_NaveNodrizaAttr);
     }
     else
     {
         Id_NaveNodrizaAttr = ONInt.Null;
     }
 }
 public NaveNodrizaOid(NaveNodrizaOid oid)
     : base("NaveNodriza")
 {
     if (oid != null)
     {
         Id_NaveNodrizaAttr = new ONInt(oid.Id_NaveNodrizaAttr);
     }
     else
     {
         Id_NaveNodrizaAttr = ONInt.Null;
     }
 }
        /// <summary>
        /// Converts an OID into XML in order to put it in XML message response
        /// </summary>
        /// <param name="xmlWriter">XML with the response message</param>
        /// <param name="oid">OID that will be insert into XML message</param>
        /// <param name="dtdVersion">Version of DTD that follows the XML message</param>
        /// <param name="xmlElement">Element in the XML message in order to convert in the right form of the XML</param>
        public static void ON2XML(XmlWriter xmlWriter, NaveNodrizaOid oid, double dtdVersion, string xmlElement)
        {
            if (oid == null)
                xmlWriter.WriteElementString(ONXml.XMLTAG_NULL, null);
            else
            {
                xmlWriter.WriteStartElement(ONXml.XMLTAG_OID);
                xmlWriter.WriteAttributeString(ONXml.XMLATT_CLASS, "NaveNodriza");
                ONXmlAutonumeric.ON2XML(xmlWriter, oid.Id_NaveNodrizaAttr, dtdVersion, xmlElement);

                xmlWriter.WriteEndElement(); // OID
            }
        }
 internal void Delete_instanceServ(NaveNodrizaOid p_thisNaveNodrizaArg)
 {
     if (Instance != null)
     {
         ONFilterList onfilt = new ONFilterList();
         onfilt.Add("QueryByOid", new QueryByOidFilter(Instance.Oid));
         Instance.Find(onfilt);
     }
     // Execute service
     NaveNodrizaAction lAction = new NaveNodrizaAction(OnContext);
     lAction.Instance = Instance;
     lAction.Delete_instanceServ(p_thisNaveNodrizaArg);
 }
        public override bool Equals(object oid)
        {
            NaveNodrizaOid lOid = null;

            if (oid is NaveNodrizaOid)
            {
                lOid = oid as NaveNodrizaOid;
            }
            else if (oid is NaveNodrizaInstance)
            {
                lOid = (oid as NaveNodrizaInstance).Oid;
            }

            if ((object)lOid == null)
            {
                return(false);
            }

            return(lOid.Id_NaveNodrizaAttr.Equals(Id_NaveNodrizaAttr));
        }
        public override void Copy(ONInstance instance)
        {
            NaveNodrizaInstance linstance = instance as NaveNodrizaInstance;

            Oid = new NaveNodrizaOid(linstance.Oid);

            Nombre_NaveNodrizaAttr = new ONString(linstance.Nombre_NaveNodrizaAttr);
            StateObj = new ONString(linstance.StateObj);

            base.Copy(instance);
        }
        /// <summary>
        /// Extracts the OID from the XML message and converts it in structures of the application
        /// </summary>
        /// <param name="xmlReader">XML with the request message</param>
        /// <param name="dtdVersion">Version of DTD that follows the XML message</param>
        public static NaveNodrizaOid XML2ON(XmlReader xmlReader, double dtdVersion)
        {
            try
            {
                if (xmlReader.IsStartElement(ONXml.XMLTAG_NULL))
                {
                    xmlReader.Skip();
                    return NaveNodrizaXml.Null;
                }

                if (!xmlReader.IsStartElement(ONXml.XMLTAG_OID))
                    throw new ONXMLStructureException(null, ONXml.XMLTAG_OID);
            }
            catch(Exception e)
            {
                throw new ONXMLStructureException(e, ONXml.XMLTAG_OID);
            }

            string lClass = xmlReader.GetAttribute("Class");

            if (string.Compare(lClass, "NaveNodriza", true) != 0)
                throw new ONXMLOIDWrongClassException(null, "Clas_1347649273856884_Alias", "NaveNodriza", lClass);

            NaveNodrizaOid lOid = new NaveNodrizaOid();
            xmlReader.ReadStartElement(ONXml.XMLTAG_OID);

            try
            {
                lOid.Id_NaveNodrizaAttr = ONXmlAutonumeric.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_OIDFIELD);
            }
            catch(Exception e)
            {
                throw new ONXMLOIDFieldException(e,"Clas_1347649273856884_Alias", "NaveNodriza", "Clas_1347649273856884Atr_1_Alias", "id_NaveNodriza");
            }

            try
            {
                xmlReader.ReadEndElement();
            }
            catch
            {
                throw new ONXMLStructureException(null, ONXml.XMLTAG_OID);
            }

            return lOid;
        }
        public void Delete_instanceServ(NaveNodrizaOid p_thisNaveNodrizaArg)
        {
            // Create new context
            using (ONServiceContext lOnContext = new ONServiceContext(OnContext))
            {
                // Change to Transactional OnContext
                Instance.OnContext = lOnContext;

                // Call Executive
                NaveNodrizaExecutive lExecutive = new NaveNodrizaExecutive();
                lExecutive.OnContext = lOnContext;
                lExecutive.Instance = Instance;
                lExecutive.Delete_instanceServ(p_thisNaveNodrizaArg);

                // Change to Non-Transactional OnContext
                Instance.OnContext = OnContext;
            }
        }
 /// <summary>This method adds to the SQL statement the part that fixes the instance</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="oid">OID to fix the instance in the SQL statement</param>
 /// <param name="isLinkedTo">The alias belongs to a role in a linked To element</param>
 public static void FixInstance(ONSqlSelect onSql, ONPath onPath, ONPath processedOnPath, NaveNodrizaOid oid, bool isLinkedTo)
 {
     if ((onPath != null) && (string.Compare(onPath.Path, "agent", true) == 0))
     {
         if (onSql.GetParameter("agent") == null)
         {
             string lAlias = AddPath(onSql, JoinType.InnerJoin, "NaveNodriza", onPath, processedOnPath, "NaveNodriza", false, isLinkedTo);
             onSql.AddWhere(lAlias + "." + CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA + " = ?");
             onSql.AddWhereParameter("agent", oid.Id_NaveNodrizaAttr);
         }
     }
     else
     {
         string lAlias = AddPath(onSql, JoinType.InnerJoin, "NaveNodriza", onPath, processedOnPath, "", false, isLinkedTo);
         onSql.AddWhere(lAlias + "." + CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA + " = ?");
         onSql.AddWhereParameter("", oid.Id_NaveNodrizaAttr);
     }
 }
 /// <summary>This method adds to the SQL statement the part that fixes the instance</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="oid">OID to fix the instance in the SQL statement</param>
 public static void FixInstance(ONSqlSelect onSql, ONPath onPath, ONPath processedOnPath, NaveNodrizaOid oid)
 {
     FixInstance(onSql, onPath, processedOnPath, oid, false);
 }