/// <summary> /// Loads a <see cref="C09_Region_Child"/> object from the given <see cref="C09_Region_ChildDto"/>. /// </summary> /// <param name="data">The C09_Region_ChildDto to use.</param> private void Fetch(C09_Region_ChildDto data) { // Value properties LoadProperty(Region_Child_NameProperty, data.Region_Child_Name); var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private C09_Region_ChildDto Fetch(IDataReader data) { var c09_Region_Child = new C09_Region_ChildDto(); using (var dr = new SafeDataReader(data)) { if (dr.Read()) { c09_Region_Child.Region_Child_Name = dr.GetString("Region_Child_Name"); } } return(c09_Region_Child); }
/// <summary> /// Inserts a new C09_Region_Child object in the database. /// </summary> /// <param name="c09_Region_Child">The C09 Region Child DTO.</param> /// <returns>The new <see cref="C09_Region_ChildDto"/>.</returns> public C09_Region_ChildDto Insert(C09_Region_ChildDto c09_Region_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddC09_Region_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Region_ID1", c09_Region_Child.Parent_Region_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Region_Child_Name", c09_Region_Child.Region_Child_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); } } return(c09_Region_Child); }
/// <summary> /// Updates in the database all changes made to the C09_Region_Child object. /// </summary> /// <param name="c09_Region_Child">The C09 Region Child DTO.</param> /// <returns>The updated <see cref="C09_Region_ChildDto"/>.</returns> public C09_Region_ChildDto Update(C09_Region_ChildDto c09_Region_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateC09_Region_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Region_ID1", c09_Region_Child.Parent_Region_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Region_Child_Name", c09_Region_Child.Region_Child_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("C09_Region_Child"); } } } return(c09_Region_Child); }
private void Child_Insert(C08_Region parent) { var dto = new C09_Region_ChildDto(); dto.Parent_Region_ID = parent.Region_ID; dto.Region_Child_Name = Region_Child_Name; using (var dalManager = DalFactorySelfLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IC09_Region_ChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); } }