private void Child_Update() { if (!IsDirty) { return; } var dto = new B10_CityDto(); dto.City_ID = City_ID; dto.City_Name = City_Name; using (var dalManager = DalFactoryParentLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IB10_CityDal>(); 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="B10_City"/> object from the given B10_CityDto. /// </summary> /// <param name="data">The <see cref="B10_CityDto"/>.</param> /// <returns>A reference to the fetched <see cref="B10_City"/> object.</returns> internal static B10_City GetB10_City(B10_CityDto data) { B10_City obj = new B10_City(); obj.Fetch(data); obj.LoadProperty(B11_CityRoadObjectsProperty, new B11_CityRoadColl()); return(obj); }
/// <summary> /// Loads a <see cref="B10_City"/> object from the given <see cref="B10_CityDto"/>. /// </summary> /// <param name="data">The B10_CityDto to use.</param> private void Fetch(B10_CityDto data) { // Value properties LoadProperty(City_IDProperty, data.City_ID); LoadProperty(City_NameProperty, data.City_Name); // parent properties parent_Region_ID = data.Parent_Region_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
/// <summary> /// Factory method. Loads a <see cref="B10_City"/> object from the given B10_CityDto. /// </summary> /// <param name="data">The <see cref="B10_CityDto"/>.</param> /// <returns>A reference to the fetched <see cref="B10_City"/> object.</returns> internal static B10_City GetB10_City(B10_CityDto data) { B10_City obj = new B10_City(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.LoadProperty(B11_CityRoadObjectsProperty, B11_CityRoadColl.NewB11_CityRoadColl()); obj.MarkOld(); return(obj); }
private B10_CityDto FetchB10_City(SafeDataReader dr) { var b10_City = new B10_CityDto(); // Value properties b10_City.City_ID = dr.GetInt32("City_ID"); b10_City.City_Name = dr.GetString("City_Name"); // parent properties b10_City.Parent_Region_ID = dr.GetInt32("Parent_Region_ID"); return(b10_City); }
/// <summary> /// Inserts a new B10_City object in the database. /// </summary> /// <param name="b10_City">The B10 City DTO.</param> /// <returns>The new <see cref="B10_CityDto"/>.</returns> public B10_CityDto Insert(B10_CityDto b10_City) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddB10_City", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Parent_Region_ID", b10_City.Parent_Region_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@City_ID", b10_City.City_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@City_Name", b10_City.City_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); b10_City.City_ID = (int)cmd.Parameters["@City_ID"].Value; } } return(b10_City); }
/// <summary> /// Updates in the database all changes made to the B10_City object. /// </summary> /// <param name="b10_City">The B10 City DTO.</param> /// <returns>The updated <see cref="B10_CityDto"/>.</returns> public B10_CityDto Update(B10_CityDto b10_City) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateB10_City", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@City_ID", b10_City.City_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@City_Name", b10_City.City_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("B10_City"); } } } return(b10_City); }
private void Child_Insert(B08_Region parent) { var dto = new B10_CityDto(); dto.Parent_Region_ID = parent.Region_ID; dto.City_Name = City_Name; using (var dalManager = DalFactoryParentLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IB10_CityDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); LoadProperty(City_IDProperty, resultDto.City_ID); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); // flushes all pending data operations FieldManager.UpdateChildren(this); } }