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

            var dto = new C04_SubContinentDto();

            dto.SubContinent_ID   = SubContinent_ID;
            dto.SubContinent_Name = SubContinent_Name;
            using (var dalManager = DalFactorySelfLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IC04_SubContinentDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Factory method. Loads a <see cref="C04_SubContinent"/> object from the given C04_SubContinentDto.
        /// </summary>
        /// <param name="data">The <see cref="C04_SubContinentDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="C04_SubContinent"/> object.</returns>
        internal static C04_SubContinent GetC04_SubContinent(C04_SubContinentDto data)
        {
            C04_SubContinent obj = new C04_SubContinent();

            obj.Fetch(data);
            return(obj);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads a <see cref="C04_SubContinent"/> object from the given <see cref="C04_SubContinentDto"/>.
        /// </summary>
        /// <param name="data">The C04_SubContinentDto to use.</param>
        private void Fetch(C04_SubContinentDto data)
        {
            // Value properties
            LoadProperty(SubContinent_IDProperty, data.SubContinent_ID);
            LoadProperty(SubContinent_NameProperty, data.SubContinent_Name);
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Exemplo n.º 4
0
        private C04_SubContinentDto Fetch(SafeDataReader dr)
        {
            var c04_SubContinent = new C04_SubContinentDto();

            // Value properties
            c04_SubContinent.SubContinent_ID   = dr.GetInt32("SubContinent_ID");
            c04_SubContinent.SubContinent_Name = dr.GetString("SubContinent_Name");

            return(c04_SubContinent);
        }
        /// <summary>
        /// Factory method. Loads a <see cref="C04_SubContinent"/> object from the given C04_SubContinentDto.
        /// </summary>
        /// <param name="data">The <see cref="C04_SubContinentDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="C04_SubContinent"/> object.</returns>
        internal static C04_SubContinent GetC04_SubContinent(C04_SubContinentDto data)
        {
            C04_SubContinent obj = new C04_SubContinent();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.MarkOld();
            return(obj);
        }
 /// <summary>
 /// Inserts a new C04_SubContinent object in the database.
 /// </summary>
 /// <param name="c04_SubContinent">The C04 Sub Continent DTO.</param>
 /// <returns>The new <see cref="C04_SubContinentDto"/>.</returns>
 public C04_SubContinentDto Insert(C04_SubContinentDto c04_SubContinent)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddC04_SubContinent", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Parent_Continent_ID", c04_SubContinent.Parent_Continent_ID).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@SubContinent_ID", c04_SubContinent.SubContinent_ID).Direction      = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@SubContinent_Name", c04_SubContinent.SubContinent_Name).DbType     = DbType.String;
             cmd.ExecuteNonQuery();
             c04_SubContinent.SubContinent_ID = (int)cmd.Parameters["@SubContinent_ID"].Value;
         }
     }
     return(c04_SubContinent);
 }
 /// <summary>
 /// Updates in the database all changes made to the C04_SubContinent object.
 /// </summary>
 /// <param name="c04_SubContinent">The C04 Sub Continent DTO.</param>
 /// <returns>The updated <see cref="C04_SubContinentDto"/>.</returns>
 public C04_SubContinentDto Update(C04_SubContinentDto c04_SubContinent)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateC04_SubContinent", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@SubContinent_ID", c04_SubContinent.SubContinent_ID).DbType     = DbType.Int32;
             cmd.Parameters.AddWithValue("@SubContinent_Name", c04_SubContinent.SubContinent_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("C04_SubContinent");
             }
         }
     }
     return(c04_SubContinent);
 }
        private void Child_Insert(C02_Continent parent)
        {
            var dto = new C04_SubContinentDto();

            dto.Parent_Continent_ID = parent.Continent_ID;
            dto.SubContinent_Name   = SubContinent_Name;
            using (var dalManager = DalFactorySelfLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IC04_SubContinentDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(SubContinent_IDProperty, resultDto.SubContinent_ID);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }