/// <summary> /// Loads a <see cref="D07_Country_Child"/> object from the given <see cref="D07_Country_ChildDto"/>. /// </summary> /// <param name="data">The D07_Country_ChildDto to use.</param> private void Fetch(D07_Country_ChildDto data) { // Value properties LoadProperty(Country_Child_NameProperty, data.Country_Child_Name); var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private D07_Country_ChildDto Fetch(IDataReader data) { var d07_Country_Child = new D07_Country_ChildDto(); using (var dr = new SafeDataReader(data)) { if (dr.Read()) { d07_Country_Child.Country_Child_Name = dr.GetString("Country_Child_Name"); } } return(d07_Country_Child); }
/// <summary> /// Inserts a new D07_Country_Child object in the database. /// </summary> /// <param name="d07_Country_Child">The D07 Country Child DTO.</param> /// <returns>The new <see cref="D07_Country_ChildDto"/>.</returns> public D07_Country_ChildDto Insert(D07_Country_ChildDto d07_Country_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddD07_Country_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Country_ID1", d07_Country_Child.Parent_Country_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Country_Child_Name", d07_Country_Child.Country_Child_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); } } return(d07_Country_Child); }
/// <summary> /// Updates in the database all changes made to the D07_Country_Child object. /// </summary> /// <param name="d07_Country_Child">The D07 Country Child DTO.</param> /// <returns>The updated <see cref="D07_Country_ChildDto"/>.</returns> public D07_Country_ChildDto Update(D07_Country_ChildDto d07_Country_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateD07_Country_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Country_ID1", d07_Country_Child.Parent_Country_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Country_Child_Name", d07_Country_Child.Country_Child_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("D07_Country_Child"); } } } return(d07_Country_Child); }
private void Child_Insert(D06_Country parent) { var dto = new D07_Country_ChildDto(); dto.Parent_Country_ID = parent.Country_ID; dto.Country_Child_Name = Country_Child_Name; using (var dalManager = DalFactorySelfLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <ID07_Country_ChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); } }