/// <summary> /// Factory method. Loads a <see cref="E09_Region_Child"/> object from the given E09_Region_ChildDto. /// </summary> /// <param name="data">The <see cref="E09_Region_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="E09_Region_Child"/> object.</returns> internal static E09_Region_Child GetE09_Region_Child(E09_Region_ChildDto data) { E09_Region_Child obj = new E09_Region_Child(); obj.Fetch(data); return(obj); }
/// <summary> /// Loads a <see cref="E09_Region_Child"/> object from the given <see cref="E09_Region_ChildDto"/>. /// </summary> /// <param name="data">The E09_Region_ChildDto to use.</param> private void Fetch(E09_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); }
/// <summary> /// Factory method. Loads a <see cref="E09_Region_Child"/> object from the given E09_Region_ChildDto. /// </summary> /// <param name="data">The <see cref="E09_Region_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="E09_Region_Child"/> object.</returns> internal static E09_Region_Child GetE09_Region_Child(E09_Region_ChildDto data) { E09_Region_Child obj = new E09_Region_Child(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); return(obj); }
private E09_Region_ChildDto FetchE09_Region_Child(SafeDataReader dr) { var e09_Region_Child = new E09_Region_ChildDto(); // Value properties e09_Region_Child.Region_Child_Name = dr.GetString("Region_Child_Name"); // parent properties e09_Region_Child.Parent_Region_ID = dr.GetInt32("Region_ID1"); return(e09_Region_Child); }
/// <summary> /// Inserts a new E09_Region_Child object in the database. /// </summary> /// <param name="e09_Region_Child">The E09 Region Child DTO.</param> /// <returns>The new <see cref="E09_Region_ChildDto"/>.</returns> public E09_Region_ChildDto Insert(E09_Region_ChildDto e09_Region_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddE09_Region_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Region_ID1", e09_Region_Child.Parent_Region_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Region_Child_Name", e09_Region_Child.Region_Child_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); } } return(e09_Region_Child); }
/// <summary> /// Updates in the database all changes made to the E09_Region_Child object. /// </summary> /// <param name="e09_Region_Child">The E09 Region Child DTO.</param> /// <returns>The updated <see cref="E09_Region_ChildDto"/>.</returns> public E09_Region_ChildDto Update(E09_Region_ChildDto e09_Region_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateE09_Region_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Region_ID1", e09_Region_Child.Parent_Region_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Region_Child_Name", e09_Region_Child.Region_Child_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("E09_Region_Child"); } } } return(e09_Region_Child); }
private void Child_Insert(E08_Region parent) { var dto = new E09_Region_ChildDto(); dto.Parent_Region_ID = parent.Region_ID; dto.Region_Child_Name = Region_Child_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IE09_Region_ChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); } }