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