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