/// <summary> /// Factory method. Loads a <see cref="F12_CityRoad"/> object from the given F12_CityRoadDto. /// </summary> /// <param name="data">The <see cref="F12_CityRoadDto"/>.</param> /// <returns>A reference to the fetched <see cref="F12_CityRoad"/> object.</returns> internal static F12_CityRoad GetF12_CityRoad(F12_CityRoadDto data) { F12_CityRoad obj = new F12_CityRoad(); obj.Fetch(data); return(obj); }
/// <summary> /// Factory method. Loads a <see cref="F12_CityRoad"/> object from the given F12_CityRoadDto. /// </summary> /// <param name="data">The <see cref="F12_CityRoadDto"/>.</param> /// <returns>A reference to the fetched <see cref="F12_CityRoad"/> object.</returns> internal static F12_CityRoad GetF12_CityRoad(F12_CityRoadDto data) { F12_CityRoad obj = new F12_CityRoad(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); return(obj); }
/// <summary> /// Loads a <see cref="F12_CityRoad"/> object from the given <see cref="F12_CityRoadDto"/>. /// </summary> /// <param name="data">The F12_CityRoadDto to use.</param> private void Fetch(F12_CityRoadDto data) { // Value properties CityRoad_ID = data.CityRoad_ID; CityRoad_Name = data.CityRoad_Name; // parent properties parent_City_ID = data.Parent_City_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private F12_CityRoadDto FetchF12_CityRoad(SafeDataReader dr) { var f12_CityRoad = new F12_CityRoadDto(); // Value properties f12_CityRoad.CityRoad_ID = dr.GetInt32("CityRoad_ID"); f12_CityRoad.CityRoad_Name = dr.GetString("CityRoad_Name"); // parent properties f12_CityRoad.Parent_City_ID = dr.GetInt32("Parent_City_ID"); return(f12_CityRoad); }
/// <summary> /// Inserts a new F12_CityRoad object in the database. /// </summary> /// <param name="f12_CityRoad">The F12 City Road DTO.</param> /// <returns>The new <see cref="F12_CityRoadDto"/>.</returns> public F12_CityRoadDto Insert(F12_CityRoadDto f12_CityRoad) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddF12_CityRoad", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Parent_City_ID", f12_CityRoad.Parent_City_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@CityRoad_ID", f12_CityRoad.CityRoad_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@CityRoad_Name", f12_CityRoad.CityRoad_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); f12_CityRoad.CityRoad_ID = (int)cmd.Parameters["@CityRoad_ID"].Value; } } return(f12_CityRoad); }
/// <summary> /// Updates in the database all changes made to the F12_CityRoad object. /// </summary> /// <param name="f12_CityRoad">The F12 City Road DTO.</param> /// <returns>The updated <see cref="F12_CityRoadDto"/>.</returns> public F12_CityRoadDto Update(F12_CityRoadDto f12_CityRoad) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateF12_CityRoad", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CityRoad_ID", f12_CityRoad.CityRoad_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@CityRoad_Name", f12_CityRoad.CityRoad_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("F12_CityRoad"); } } } return(f12_CityRoad); }
private void Child_Insert(F10_City parent) { var dto = new F12_CityRoadDto(); dto.Parent_City_ID = parent.City_ID; dto.CityRoad_Name = CityRoad_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IF12_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 F12_CityRoadDto(); dto.CityRoad_ID = CityRoad_ID; dto.CityRoad_Name = CityRoad_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IF12_CityRoadDal>(); using (BypassPropertyChecks) { var resultDto = dal.Update(dto); args = new DataPortalHookArgs(resultDto); } OnUpdatePost(args); } }