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