/// <summary>
        /// Factory method. Loads a <see cref="F07_Country_ReChild"/> object from the given F07_Country_ReChildDto.
        /// </summary>
        /// <param name="data">The <see cref="F07_Country_ReChildDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="F07_Country_ReChild"/> object.</returns>
        internal static F07_Country_ReChild GetF07_Country_ReChild(F07_Country_ReChildDto data)
        {
            F07_Country_ReChild obj = new F07_Country_ReChild();

            obj.Fetch(data);
            // check all object rules and property rules
            obj.BusinessRules.CheckRules();
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="F07_Country_ReChild"/> object from the given <see cref="F07_Country_ReChildDto"/>.
        /// </summary>
        /// <param name="data">The F07_Country_ReChildDto to use.</param>
        private void Fetch(F07_Country_ReChildDto data)
        {
            // Value properties
            LoadProperty(Country_Child_NameProperty, data.Country_Child_Name);
            // parent properties
            country_ID2 = data.Parent_Country_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Exemple #3
0
        private F07_Country_ReChildDto FetchF07_Country_ReChild(SafeDataReader dr)
        {
            var f07_Country_ReChild = new F07_Country_ReChildDto();

            // Value properties
            f07_Country_ReChild.Country_Child_Name = dr.GetString("Country_Child_Name");
            // parent properties
            f07_Country_ReChild.Parent_Country_ID = dr.GetInt32("Country_ID2");

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

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.MarkOld();
            // check all object rules and property rules
            obj.BusinessRules.CheckRules();
            return(obj);
        }
 /// <summary>
 /// Inserts a new F07_Country_ReChild object in the database.
 /// </summary>
 /// <param name="f07_Country_ReChild">The F07 Country Re Child DTO.</param>
 /// <returns>The new <see cref="F07_Country_ReChildDto"/>.</returns>
 public F07_Country_ReChildDto Insert(F07_Country_ReChildDto f07_Country_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddF07_Country_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID2", f07_Country_ReChild.Parent_Country_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Child_Name", f07_Country_ReChild.Country_Child_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
         }
     }
     return(f07_Country_ReChild);
 }
 /// <summary>
 /// Updates in the database all changes made to the F07_Country_ReChild object.
 /// </summary>
 /// <param name="f07_Country_ReChild">The F07 Country Re Child DTO.</param>
 /// <returns>The updated <see cref="F07_Country_ReChildDto"/>.</returns>
 public F07_Country_ReChildDto Update(F07_Country_ReChildDto f07_Country_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateF07_Country_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID2", f07_Country_ReChild.Parent_Country_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Child_Name", f07_Country_ReChild.Country_Child_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("F07_Country_ReChild");
             }
         }
     }
     return(f07_Country_ReChild);
 }
        private void Child_Insert(F06_Country parent)
        {
            var dto = new F07_Country_ReChildDto();

            dto.Parent_Country_ID  = parent.Country_ID;
            dto.Country_Child_Name = Country_Child_Name;
            using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IF07_Country_ReChildDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
            }
        }