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

            obj.Fetch(data);
            // check all object rules and property rules
            obj.BusinessRules.CheckRules();
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="A07_Country_ReChild"/> object from the given <see cref="A07_Country_ReChildDto"/>.
        /// </summary>
        /// <param name="data">The A07_Country_ReChildDto to use.</param>
        private void Fetch(A07_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);
        }
Esempio n. 3
0
        private A07_Country_ReChildDto FetchA07_Country_ReChild(SafeDataReader dr)
        {
            var a07_Country_ReChild = new A07_Country_ReChildDto();

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

            return(a07_Country_ReChild);
        }
Esempio n. 4
0
        /// <summary>
        /// Factory method. Loads a <see cref="A07_Country_ReChild"/> object from the given A07_Country_ReChildDto.
        /// </summary>
        /// <param name="data">The <see cref="A07_Country_ReChildDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="A07_Country_ReChild"/> object.</returns>
        internal static A07_Country_ReChild GetA07_Country_ReChild(A07_Country_ReChildDto data)
        {
            A07_Country_ReChild obj = new A07_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 A07_Country_ReChild object in the database.
 /// </summary>
 /// <param name="a07_Country_ReChild">The A07 Country Re Child DTO.</param>
 /// <returns>The new <see cref="A07_Country_ReChildDto"/>.</returns>
 public A07_Country_ReChildDto Insert(A07_Country_ReChildDto a07_Country_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddA07_Country_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID2", a07_Country_ReChild.Parent_Country_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Child_Name", a07_Country_ReChild.Country_Child_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
         }
     }
     return(a07_Country_ReChild);
 }
 /// <summary>
 /// Updates in the database all changes made to the A07_Country_ReChild object.
 /// </summary>
 /// <param name="a07_Country_ReChild">The A07 Country Re Child DTO.</param>
 /// <returns>The updated <see cref="A07_Country_ReChildDto"/>.</returns>
 public A07_Country_ReChildDto Update(A07_Country_ReChildDto a07_Country_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateA07_Country_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID2", a07_Country_ReChild.Parent_Country_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Child_Name", a07_Country_ReChild.Country_Child_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("A07_Country_ReChild");
             }
         }
     }
     return(a07_Country_ReChild);
 }
Esempio n. 7
0
        private void Child_Insert(A06_Country parent)
        {
            var dto = new A07_Country_ReChildDto();

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