private void Child_Update()
        {
            if (!IsDirty)
            {
                return;
            }

            var dto = new H08_RegionDto();

            dto.Region_ID   = Region_ID;
            dto.Region_Name = Region_Name;
            using (var dalManager = DalFactorySelfLoadSoftDelete.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IH08_RegionDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }
        /// <summary>
        /// Factory method. Loads a <see cref="H08_Region"/> object from the given H08_RegionDto.
        /// </summary>
        /// <param name="data">The <see cref="H08_RegionDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="H08_Region"/> object.</returns>
        internal static H08_Region GetH08_Region(H08_RegionDto data)
        {
            H08_Region obj = new H08_Region();

            obj.Fetch(data);
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="H08_Region"/> object from the given <see cref="H08_RegionDto"/>.
        /// </summary>
        /// <param name="data">The H08_RegionDto to use.</param>
        private void Fetch(H08_RegionDto data)
        {
            // Value properties
            LoadProperty(Region_IDProperty, data.Region_ID);
            LoadProperty(Region_NameProperty, data.Region_Name);
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
        /// <summary>
        /// Factory method. Loads a <see cref="H08_Region"/> object from the given H08_RegionDto.
        /// </summary>
        /// <param name="data">The <see cref="H08_RegionDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="H08_Region"/> object.</returns>
        internal static H08_Region GetH08_Region(H08_RegionDto data)
        {
            H08_Region obj = new H08_Region();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.MarkOld();
            return(obj);
        }
Example #5
0
        private H08_RegionDto Fetch(SafeDataReader dr)
        {
            var h08_Region = new H08_RegionDto();

            // Value properties
            h08_Region.Region_ID   = dr.GetInt32("Region_ID");
            h08_Region.Region_Name = dr.GetString("Region_Name");

            return(h08_Region);
        }
 /// <summary>
 /// Inserts a new H08_Region object in the database.
 /// </summary>
 /// <param name="h08_Region">The H08 Region DTO.</param>
 /// <returns>The new <see cref="H08_RegionDto"/>.</returns>
 public H08_RegionDto Insert(H08_RegionDto h08_Region)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddH08_Region", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Parent_Country_ID", h08_Region.Parent_Country_ID).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_ID", h08_Region.Region_ID).Direction  = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@Region_Name", h08_Region.Region_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
             h08_Region.Region_ID = (int)cmd.Parameters["@Region_ID"].Value;
         }
     }
     return(h08_Region);
 }
 /// <summary>
 /// Updates in the database all changes made to the H08_Region object.
 /// </summary>
 /// <param name="h08_Region">The H08 Region DTO.</param>
 /// <returns>The updated <see cref="H08_RegionDto"/>.</returns>
 public H08_RegionDto Update(H08_RegionDto h08_Region)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateH08_Region", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Region_ID", h08_Region.Region_ID).DbType     = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_Name", h08_Region.Region_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("H08_Region");
             }
         }
     }
     return(h08_Region);
 }
        private void Child_Insert(H06_Country parent)
        {
            var dto = new H08_RegionDto();

            dto.Parent_Country_ID = parent.Country_ID;
            dto.Region_Name       = Region_Name;
            using (var dalManager = DalFactorySelfLoadSoftDelete.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IH08_RegionDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(Region_IDProperty, resultDto.Region_ID);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }