private void Child_Update(C04_SubContinent parent) { if (!IsDirty) { return; } var dto = new C05_SubContinent_ChildDto(); dto.Parent_SubContinent_ID = parent.SubContinent_ID; dto.SubContinent_Child_Name = SubContinent_Child_Name; dto.RowVersion = _rowVersion; using (var dalManager = DalFactorySelfLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IC05_SubContinent_ChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Update(dto); _rowVersion = resultDto.RowVersion; args = new DataPortalHookArgs(resultDto); } OnUpdatePost(args); } }
/// <summary> /// Loads a <see cref="C05_SubContinent_Child"/> object from the given <see cref="C05_SubContinent_ChildDto"/>. /// </summary> /// <param name="data">The C05_SubContinent_ChildDto to use.</param> private void Fetch(C05_SubContinent_ChildDto data) { // Value properties LoadProperty(SubContinent_Child_NameProperty, data.SubContinent_Child_Name); _rowVersion = data.RowVersion; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private C05_SubContinent_ChildDto Fetch(IDataReader data) { var c05_SubContinent_Child = new C05_SubContinent_ChildDto(); using (var dr = new SafeDataReader(data)) { if (dr.Read()) { c05_SubContinent_Child.SubContinent_Child_Name = dr.GetString("SubContinent_Child_Name"); c05_SubContinent_Child.RowVersion = dr.GetValue("RowVersion") as byte[]; } } return(c05_SubContinent_Child); }
/// <summary> /// Inserts a new C05_SubContinent_Child object in the database. /// </summary> /// <param name="c05_SubContinent_Child">The C05 Sub Continent Child DTO.</param> /// <returns>The new <see cref="C05_SubContinent_ChildDto"/>.</returns> public C05_SubContinent_ChildDto Insert(C05_SubContinent_ChildDto c05_SubContinent_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddC05_SubContinent_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID1", c05_SubContinent_Child.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Child_Name", c05_SubContinent_Child.SubContinent_Child_Name).DbType = DbType.String; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); c05_SubContinent_Child.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(c05_SubContinent_Child); }
/// <summary> /// Updates in the database all changes made to the C05_SubContinent_Child object. /// </summary> /// <param name="c05_SubContinent_Child">The C05 Sub Continent Child DTO.</param> /// <returns>The updated <see cref="C05_SubContinent_ChildDto"/>.</returns> public C05_SubContinent_ChildDto Update(C05_SubContinent_ChildDto c05_SubContinent_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateC05_SubContinent_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID1", c05_SubContinent_Child.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Child_Name", c05_SubContinent_Child.SubContinent_Child_Name).DbType = DbType.String; cmd.Parameters.AddWithValue("@RowVersion", c05_SubContinent_Child.RowVersion).DbType = DbType.Binary; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("C05_SubContinent_Child"); } c05_SubContinent_Child.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(c05_SubContinent_Child); }