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

            var dto = new A04_SubContinentDto();

            dto.SubContinent_ID   = SubContinent_ID;
            dto.SubContinent_Name = SubContinent_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IA04_SubContinentDal>();
                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="A04_SubContinent"/> object from the given A04_SubContinentDto.
        /// </summary>
        /// <param name="data">The <see cref="A04_SubContinentDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="A04_SubContinent"/> object.</returns>
        internal static A04_SubContinent GetA04_SubContinent(A04_SubContinentDto data)
        {
            A04_SubContinent obj = new A04_SubContinent();

            obj.Fetch(data);
            obj.LoadProperty(A05_CountryObjectsProperty, new A05_CountryColl());
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="A04_SubContinent"/> object from the given <see cref="A04_SubContinentDto"/>.
        /// </summary>
        /// <param name="data">The A04_SubContinentDto to use.</param>
        private void Fetch(A04_SubContinentDto data)
        {
            // Value properties
            LoadProperty(SubContinent_IDProperty, data.SubContinent_ID);
            LoadProperty(SubContinent_NameProperty, data.SubContinent_Name);
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Beispiel #4
0
        private A04_SubContinentDto FetchA04_SubContinent(SafeDataReader dr)
        {
            var a04_SubContinent = new A04_SubContinentDto();

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

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

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

            dto.Parent_Continent_ID = parent.Continent_ID;
            dto.SubContinent_Name   = SubContinent_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IA04_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);
            }
        }