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

            obj.Fetch(data);
            // check all object rules and property rules
            obj.BusinessRules.CheckRules();
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="B11_City_ReChild"/> object from the given <see cref="B11_City_ReChildDto"/>.
        /// </summary>
        /// <param name="data">The B11_City_ReChildDto to use.</param>
        private void Fetch(B11_City_ReChildDto data)
        {
            // Value properties
            City_Child_Name = data.City_Child_Name;
            // parent properties
            city_ID2 = data.Parent_City_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Esempio n. 3
0
        private B11_City_ReChildDto FetchB11_City_ReChild(SafeDataReader dr)
        {
            var b11_City_ReChild = new B11_City_ReChildDto();

            // Value properties
            b11_City_ReChild.City_Child_Name = dr.GetString("City_Child_Name");
            // parent properties
            b11_City_ReChild.Parent_City_ID = dr.GetInt32("City_ID2");

            return(b11_City_ReChild);
        }
Esempio n. 4
0
        /// <summary>
        /// Factory method. Loads a <see cref="B11_City_ReChild"/> object from the given B11_City_ReChildDto.
        /// </summary>
        /// <param name="data">The <see cref="B11_City_ReChildDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="B11_City_ReChild"/> object.</returns>
        internal static B11_City_ReChild GetB11_City_ReChild(B11_City_ReChildDto data)
        {
            B11_City_ReChild obj = new B11_City_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 B11_City_ReChild object in the database.
 /// </summary>
 /// <param name="b11_City_ReChild">The B11 City Re Child DTO.</param>
 /// <returns>The new <see cref="B11_City_ReChildDto"/>.</returns>
 public B11_City_ReChildDto Insert(B11_City_ReChildDto b11_City_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddB11_City_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@City_ID2", b11_City_ReChild.Parent_City_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@City_Child_Name", b11_City_ReChild.City_Child_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
         }
     }
     return(b11_City_ReChild);
 }
 /// <summary>
 /// Updates in the database all changes made to the B11_City_ReChild object.
 /// </summary>
 /// <param name="b11_City_ReChild">The B11 City Re Child DTO.</param>
 /// <returns>The updated <see cref="B11_City_ReChildDto"/>.</returns>
 public B11_City_ReChildDto Update(B11_City_ReChildDto b11_City_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateB11_City_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@City_ID2", b11_City_ReChild.Parent_City_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@City_Child_Name", b11_City_ReChild.City_Child_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("B11_City_ReChild");
             }
         }
     }
     return(b11_City_ReChild);
 }
Esempio n. 7
0
        private void Child_Insert(B10_City parent)
        {
            var dto = new B11_City_ReChildDto();

            dto.Parent_City_ID  = parent.City_ID;
            dto.City_Child_Name = City_Child_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IB11_City_ReChildDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
            }
        }