private void Child_Update() { if (!IsDirty) { return; } var dto = new A10_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 <IA10_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="A10_City"/> object from the given A10_CityDto. /// </summary> /// <param name="data">The <see cref="A10_CityDto"/>.</param> /// <returns>A reference to the fetched <see cref="A10_City"/> object.</returns> internal static A10_City GetA10_City(A10_CityDto data) { A10_City obj = new A10_City(); obj.Fetch(data); obj.LoadProperty(A11_CityRoadObjectsProperty, new A11_CityRoadColl()); return(obj); }
/// <summary> /// Loads a <see cref="A10_City"/> object from the given <see cref="A10_CityDto"/>. /// </summary> /// <param name="data">The A10_CityDto to use.</param> private void Fetch(A10_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="A10_City"/> object from the given A10_CityDto. /// </summary> /// <param name="data">The <see cref="A10_CityDto"/>.</param> /// <returns>A reference to the fetched <see cref="A10_City"/> object.</returns> internal static A10_City GetA10_City(A10_CityDto data) { A10_City obj = new A10_City(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.LoadProperty(A11_CityRoadObjectsProperty, A11_CityRoadColl.NewA11_CityRoadColl()); obj.MarkOld(); return(obj); }
private A10_CityDto FetchA10_City(SafeDataReader dr) { var a10_City = new A10_CityDto(); // Value properties a10_City.City_ID = dr.GetInt32("City_ID"); a10_City.City_Name = dr.GetString("City_Name"); // parent properties a10_City.Parent_Region_ID = dr.GetInt32("Parent_Region_ID"); return(a10_City); }
/// <summary> /// Inserts a new A10_City object in the database. /// </summary> /// <param name="a10_City">The A10 City DTO.</param> /// <returns>The new <see cref="A10_CityDto"/>.</returns> public A10_CityDto Insert(A10_CityDto a10_City) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddA10_City", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Parent_Region_ID", a10_City.Parent_Region_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@City_ID", a10_City.City_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@City_Name", a10_City.City_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); a10_City.City_ID = (int)cmd.Parameters["@City_ID"].Value; } } return(a10_City); }
/// <summary> /// Updates in the database all changes made to the A10_City object. /// </summary> /// <param name="a10_City">The A10 City DTO.</param> /// <returns>The updated <see cref="A10_CityDto"/>.</returns> public A10_CityDto Update(A10_CityDto a10_City) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateA10_City", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@City_ID", a10_City.City_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@City_Name", a10_City.City_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("A10_City"); } } } return(a10_City); }
private void Child_Insert(A08_Region parent) { var dto = new A10_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 <IA10_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); } }