private void Child_Update() { if (!IsDirty) { return; } var dto = new F04_SubContinentDto(); dto.SubContinent_ID = SubContinent_ID; dto.SubContinent_Name = SubContinent_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IF04_SubContinentDal>(); using (BypassPropertyChecks) { var resultDto = dal.Update(dto); args = new DataPortalHookArgs(resultDto); } OnUpdatePost(args); // flushes all pending data operations FieldManager.UpdateChildren(this); } }
/// <summary> /// Factory method. Loads a <see cref="F04_SubContinent"/> object from the given F04_SubContinentDto. /// </summary> /// <param name="data">The <see cref="F04_SubContinentDto"/>.</param> /// <returns>A reference to the fetched <see cref="F04_SubContinent"/> object.</returns> internal static F04_SubContinent GetF04_SubContinent(F04_SubContinentDto data) { F04_SubContinent obj = new F04_SubContinent(); obj.Fetch(data); obj.LoadProperty(F05_CountryObjectsProperty, new F05_CountryColl()); return(obj); }
/// <summary> /// Loads a <see cref="F04_SubContinent"/> object from the given <see cref="F04_SubContinentDto"/>. /// </summary> /// <param name="data">The F04_SubContinentDto to use.</param> private void Fetch(F04_SubContinentDto data) { // Value properties LoadProperty(SubContinent_IDProperty, data.SubContinent_ID); LoadProperty(SubContinent_NameProperty, data.SubContinent_Name); // parent properties parent_Continent_ID = data.Parent_Continent_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
/// <summary> /// Factory method. Loads a <see cref="F04_SubContinent"/> object from the given F04_SubContinentDto. /// </summary> /// <param name="data">The <see cref="F04_SubContinentDto"/>.</param> /// <returns>A reference to the fetched <see cref="F04_SubContinent"/> object.</returns> internal static F04_SubContinent GetF04_SubContinent(F04_SubContinentDto data) { F04_SubContinent obj = new F04_SubContinent(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.LoadProperty(F05_CountryObjectsProperty, F05_CountryColl.NewF05_CountryColl()); obj.MarkOld(); return(obj); }
private F04_SubContinentDto FetchF04_SubContinent(SafeDataReader dr) { var f04_SubContinent = new F04_SubContinentDto(); // Value properties f04_SubContinent.SubContinent_ID = dr.GetInt32("SubContinent_ID"); f04_SubContinent.SubContinent_Name = dr.GetString("SubContinent_Name"); // parent properties f04_SubContinent.Parent_Continent_ID = dr.GetInt32("Parent_Continent_ID"); return(f04_SubContinent); }
/// <summary> /// Inserts a new F04_SubContinent object in the database. /// </summary> /// <param name="f04_SubContinent">The F04 Sub Continent DTO.</param> /// <returns>The new <see cref="F04_SubContinentDto"/>.</returns> public F04_SubContinentDto Insert(F04_SubContinentDto f04_SubContinent) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddF04_SubContinent", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Parent_Continent_ID", f04_SubContinent.Parent_Continent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_ID", f04_SubContinent.SubContinent_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@SubContinent_Name", f04_SubContinent.SubContinent_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); f04_SubContinent.SubContinent_ID = (int)cmd.Parameters["@SubContinent_ID"].Value; } } return(f04_SubContinent); }
/// <summary> /// Updates in the database all changes made to the F04_SubContinent object. /// </summary> /// <param name="f04_SubContinent">The F04 Sub Continent DTO.</param> /// <returns>The updated <see cref="F04_SubContinentDto"/>.</returns> public F04_SubContinentDto Update(F04_SubContinentDto f04_SubContinent) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateF04_SubContinent", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID", f04_SubContinent.SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Name", f04_SubContinent.SubContinent_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("F04_SubContinent"); } } } return(f04_SubContinent); }
private void Child_Insert(F02_Continent parent) { var dto = new F04_SubContinentDto(); dto.Parent_Continent_ID = parent.Continent_ID; dto.SubContinent_Name = SubContinent_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IF04_SubContinentDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); LoadProperty(SubContinent_IDProperty, resultDto.SubContinent_ID); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); // flushes all pending data operations FieldManager.UpdateChildren(this); } }