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