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