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

            obj.Fetch(data);
            return(obj);
        }
示例#2
0
        /// <summary>
        /// Factory method. Loads a <see cref="B09_Region_Child"/> object from the given B09_Region_ChildDto.
        /// </summary>
        /// <param name="data">The <see cref="B09_Region_ChildDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="B09_Region_Child"/> object.</returns>
        internal static B09_Region_Child GetB09_Region_Child(B09_Region_ChildDto data)
        {
            B09_Region_Child obj = new B09_Region_Child();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.MarkOld();
            return(obj);
        }
示例#3
0
        /// <summary>
        /// Loads a <see cref="B09_Region_Child"/> object from the given <see cref="B09_Region_ChildDto"/>.
        /// </summary>
        /// <param name="data">The B09_Region_ChildDto to use.</param>
        private void Fetch(B09_Region_ChildDto data)
        {
            // Value properties
            LoadProperty(Region_Child_NameProperty, data.Region_Child_Name);
            // parent properties
            region_ID1 = data.Parent_Region_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
示例#4
0
        private B09_Region_ChildDto FetchB09_Region_Child(SafeDataReader dr)
        {
            var b09_Region_Child = new B09_Region_ChildDto();

            // Value properties
            b09_Region_Child.Region_Child_Name = dr.GetString("Region_Child_Name");
            // parent properties
            b09_Region_Child.Parent_Region_ID = dr.GetInt32("Region_ID1");

            return(b09_Region_Child);
        }
示例#5
0
 /// <summary>
 /// Inserts a new B09_Region_Child object in the database.
 /// </summary>
 /// <param name="b09_Region_Child">The B09 Region Child DTO.</param>
 /// <returns>The new <see cref="B09_Region_ChildDto"/>.</returns>
 public B09_Region_ChildDto Insert(B09_Region_ChildDto b09_Region_Child)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddB09_Region_Child", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Region_ID1", b09_Region_Child.Parent_Region_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_Child_Name", b09_Region_Child.Region_Child_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
         }
     }
     return(b09_Region_Child);
 }
示例#6
0
 /// <summary>
 /// Updates in the database all changes made to the B09_Region_Child object.
 /// </summary>
 /// <param name="b09_Region_Child">The B09 Region Child DTO.</param>
 /// <returns>The updated <see cref="B09_Region_ChildDto"/>.</returns>
 public B09_Region_ChildDto Update(B09_Region_ChildDto b09_Region_Child)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateB09_Region_Child", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Region_ID1", b09_Region_Child.Parent_Region_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_Child_Name", b09_Region_Child.Region_Child_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("B09_Region_Child");
             }
         }
     }
     return(b09_Region_Child);
 }
示例#7
0
        private void Child_Insert(B08_Region parent)
        {
            var dto = new B09_Region_ChildDto();

            dto.Parent_Region_ID  = parent.Region_ID;
            dto.Region_Child_Name = Region_Child_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IB09_Region_ChildDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
            }
        }