private void Child_Update() { if (!IsDirty) { return; } var dto = new B02_ContinentDto(); dto.Continent_ID = Continent_ID; dto.Continent_Name = Continent_Name; using (var dalManager = DalFactoryParentLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IB02_ContinentDal>(); 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="B02_Continent"/> object from the given B02_ContinentDto. /// </summary> /// <param name="data">The <see cref="B02_ContinentDto"/>.</param> /// <returns>A reference to the fetched <see cref="B02_Continent"/> object.</returns> internal static B02_Continent GetB02_Continent(B02_ContinentDto data) { B02_Continent obj = new B02_Continent(); obj.Fetch(data); obj.LoadProperty(B03_SubContinentObjectsProperty, new B03_SubContinentColl()); return(obj); }
/// <summary> /// Loads a <see cref="B02_Continent"/> object from the given <see cref="B02_ContinentDto"/>. /// </summary> /// <param name="data">The B02_ContinentDto to use.</param> private void Fetch(B02_ContinentDto data) { // Value properties LoadProperty(Continent_IDProperty, data.Continent_ID); LoadProperty(Continent_NameProperty, data.Continent_Name); var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private B02_ContinentDto Fetch(SafeDataReader dr) { var b02_Continent = new B02_ContinentDto(); // Value properties b02_Continent.Continent_ID = dr.GetInt32("Continent_ID"); b02_Continent.Continent_Name = dr.GetString("Continent_Name"); return(b02_Continent); }
/// <summary> /// Factory method. Loads a <see cref="B02_Continent"/> object from the given B02_ContinentDto. /// </summary> /// <param name="data">The <see cref="B02_ContinentDto"/>.</param> /// <returns>A reference to the fetched <see cref="B02_Continent"/> object.</returns> internal static B02_Continent GetB02_Continent(B02_ContinentDto data) { B02_Continent obj = new B02_Continent(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.LoadProperty(B03_SubContinentObjectsProperty, B03_SubContinentColl.NewB03_SubContinentColl()); obj.MarkOld(); return(obj); }
/// <summary> /// Inserts a new B02_Continent object in the database. /// </summary> /// <param name="b02_Continent">The B02 Continent DTO.</param> /// <returns>The new <see cref="B02_ContinentDto"/>.</returns> public B02_ContinentDto Insert(B02_ContinentDto b02_Continent) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddB02_Continent", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Continent_ID", b02_Continent.Continent_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@Continent_Name", b02_Continent.Continent_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); b02_Continent.Continent_ID = (int)cmd.Parameters["@Continent_ID"].Value; } } return(b02_Continent); }
/// <summary> /// Updates in the database all changes made to the B02_Continent object. /// </summary> /// <param name="b02_Continent">The B02 Continent DTO.</param> /// <returns>The updated <see cref="B02_ContinentDto"/>.</returns> public B02_ContinentDto Update(B02_ContinentDto b02_Continent) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateB02_Continent", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Continent_ID", b02_Continent.Continent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Continent_Name", b02_Continent.Continent_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("B02_Continent"); } } } return(b02_Continent); }