Exemplo n.º 1
0
        /// <summary>
        /// Loads a <see cref="H07_Country_Child"/> object from the given <see cref="H07_Country_ChildDto"/>.
        /// </summary>
        /// <param name="data">The H07_Country_ChildDto to use.</param>
        private void Fetch(H07_Country_ChildDto data)
        {
            // Value properties
            LoadProperty(Country_Child_NameProperty, data.Country_Child_Name);
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
        private H07_Country_ChildDto Fetch(IDataReader data)
        {
            var h07_Country_Child = new H07_Country_ChildDto();

            using (var dr = new SafeDataReader(data))
            {
                if (dr.Read())
                {
                    h07_Country_Child.Country_Child_Name = dr.GetString("Country_Child_Name");
                }
            }
            return(h07_Country_Child);
        }
 /// <summary>
 /// Inserts a new H07_Country_Child object in the database.
 /// </summary>
 /// <param name="h07_Country_Child">The H07 Country Child DTO.</param>
 /// <returns>The new <see cref="H07_Country_ChildDto"/>.</returns>
 public H07_Country_ChildDto Insert(H07_Country_ChildDto h07_Country_Child)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddH07_Country_Child", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID1", h07_Country_Child.Parent_Country_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Child_Name", h07_Country_Child.Country_Child_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
         }
     }
     return(h07_Country_Child);
 }
 /// <summary>
 /// Updates in the database all changes made to the H07_Country_Child object.
 /// </summary>
 /// <param name="h07_Country_Child">The H07 Country Child DTO.</param>
 /// <returns>The updated <see cref="H07_Country_ChildDto"/>.</returns>
 public H07_Country_ChildDto Update(H07_Country_ChildDto h07_Country_Child)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateH07_Country_Child", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID1", h07_Country_Child.Parent_Country_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Child_Name", h07_Country_Child.Country_Child_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("H07_Country_Child");
             }
         }
     }
     return(h07_Country_Child);
 }
Exemplo n.º 5
0
        private void Child_Insert(H06_Country parent)
        {
            var dto = new H07_Country_ChildDto();

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