/// <summary> /// Factory method. Loads a <see cref="H12_CityRoad"/> object from the given H12_CityRoadDto. /// </summary> /// <param name="data">The <see cref="H12_CityRoadDto"/>.</param> /// <returns>A reference to the fetched <see cref="H12_CityRoad"/> object.</returns> internal static H12_CityRoad GetH12_CityRoad(H12_CityRoadDto data) { H12_CityRoad obj = new H12_CityRoad(); obj.Fetch(data); return(obj); }
/// <summary> /// Loads a <see cref="H12_CityRoad"/> object from the given <see cref="H12_CityRoadDto"/>. /// </summary> /// <param name="data">The H12_CityRoadDto to use.</param> private void Fetch(H12_CityRoadDto data) { // Value properties LoadProperty(CityRoad_IDProperty, data.CityRoad_ID); LoadProperty(CityRoad_NameProperty, data.CityRoad_Name); var args = new DataPortalHookArgs(data); OnFetchRead(args); }
/// <summary> /// Loads a <see cref="H12_CityRoad"/> object from the given <see cref="H12_CityRoadDto"/>. /// </summary> /// <param name="data">The H12_CityRoadDto to use.</param> private void Fetch(H12_CityRoadDto data) { // Value properties CityRoad_ID = data.CityRoad_ID; CityRoad_Name = data.CityRoad_Name; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private H12_CityRoadDto Fetch(SafeDataReader dr) { var h12_CityRoad = new H12_CityRoadDto(); // Value properties h12_CityRoad.CityRoad_ID = dr.GetInt32("CityRoad_ID"); h12_CityRoad.CityRoad_Name = dr.GetString("CityRoad_Name"); return(h12_CityRoad); }
/// <summary> /// Factory method. Loads a <see cref="H12_CityRoad"/> object from the given H12_CityRoadDto. /// </summary> /// <param name="data">The <see cref="H12_CityRoadDto"/>.</param> /// <returns>A reference to the fetched <see cref="H12_CityRoad"/> object.</returns> internal static H12_CityRoad GetH12_CityRoad(H12_CityRoadDto data) { H12_CityRoad obj = new H12_CityRoad(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); return(obj); }
/// <summary> /// Inserts a new H12_CityRoad object in the database. /// </summary> /// <param name="h12_CityRoad">The H12 City Road DTO.</param> /// <returns>The new <see cref="H12_CityRoadDto"/>.</returns> public H12_CityRoadDto Insert(H12_CityRoadDto h12_CityRoad) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddH12_CityRoad", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Parent_City_ID", h12_CityRoad.Parent_City_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@CityRoad_ID", h12_CityRoad.CityRoad_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@CityRoad_Name", h12_CityRoad.CityRoad_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); h12_CityRoad.CityRoad_ID = (int)cmd.Parameters["@CityRoad_ID"].Value; } } return(h12_CityRoad); }
/// <summary> /// Updates in the database all changes made to the H12_CityRoad object. /// </summary> /// <param name="h12_CityRoad">The H12 City Road DTO.</param> /// <returns>The updated <see cref="H12_CityRoadDto"/>.</returns> public H12_CityRoadDto Update(H12_CityRoadDto h12_CityRoad) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateH12_CityRoad", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CityRoad_ID", h12_CityRoad.CityRoad_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@CityRoad_Name", h12_CityRoad.CityRoad_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("H12_CityRoad"); } } } return(h12_CityRoad); }
private void Child_Insert(H10_City parent) { var dto = new H12_CityRoadDto(); dto.Parent_City_ID = parent.City_ID; dto.CityRoad_Name = CityRoad_Name; using (var dalManager = DalFactorySelfLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IH12_CityRoadDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); LoadProperty(CityRoad_IDProperty, resultDto.CityRoad_ID); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); } }
private void Child_Update() { if (!IsDirty) { return; } var dto = new H12_CityRoadDto(); dto.CityRoad_ID = CityRoad_ID; dto.CityRoad_Name = CityRoad_Name; using (var dalManager = DalFactorySelfLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IH12_CityRoadDal>(); using (BypassPropertyChecks) { var resultDto = dal.Update(dto); args = new DataPortalHookArgs(resultDto); } OnUpdatePost(args); } }