private void Child_Update(A04_SubContinent parent) { if (!IsDirty) { return; } var dto = new A05_SubContinent_ReChildDto(); dto.Parent_SubContinent_ID = parent.SubContinent_ID; dto.SubContinent_Child_Name = SubContinent_Child_Name; dto.RowVersion = _rowVersion; using (var dalManager = DalFactoryParentLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IA05_SubContinent_ReChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Update(dto); _rowVersion = resultDto.RowVersion; args = new DataPortalHookArgs(resultDto); } OnUpdatePost(args); } }
/// <summary> /// Factory method. Loads a <see cref="A05_SubContinent_ReChild"/> object from the given A05_SubContinent_ReChildDto. /// </summary> /// <param name="data">The <see cref="A05_SubContinent_ReChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="A05_SubContinent_ReChild"/> object.</returns> internal static A05_SubContinent_ReChild GetA05_SubContinent_ReChild(A05_SubContinent_ReChildDto data) { A05_SubContinent_ReChild obj = new A05_SubContinent_ReChild(); obj.Fetch(data); // check all object rules and property rules obj.BusinessRules.CheckRules(); return(obj); }
/// <summary> /// Loads a <see cref="A05_SubContinent_ReChild"/> object from the given <see cref="A05_SubContinent_ReChildDto"/>. /// </summary> /// <param name="data">The A05_SubContinent_ReChildDto to use.</param> private void Fetch(A05_SubContinent_ReChildDto data) { // Value properties LoadProperty(SubContinent_Child_NameProperty, data.SubContinent_Child_Name); _rowVersion = data.RowVersion; // parent properties subContinent_ID2 = data.Parent_SubContinent_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
/// <summary> /// Factory method. Loads a <see cref="A05_SubContinent_ReChild"/> object from the given A05_SubContinent_ReChildDto. /// </summary> /// <param name="data">The <see cref="A05_SubContinent_ReChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="A05_SubContinent_ReChild"/> object.</returns> internal static A05_SubContinent_ReChild GetA05_SubContinent_ReChild(A05_SubContinent_ReChildDto data) { A05_SubContinent_ReChild obj = new A05_SubContinent_ReChild(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); // check all object rules and property rules obj.BusinessRules.CheckRules(); return(obj); }
private A05_SubContinent_ReChildDto FetchA05_SubContinent_ReChild(SafeDataReader dr) { var a05_SubContinent_ReChild = new A05_SubContinent_ReChildDto(); // Value properties a05_SubContinent_ReChild.SubContinent_Child_Name = dr.GetString("SubContinent_Child_Name"); a05_SubContinent_ReChild.RowVersion = dr.GetValue("RowVersion") as byte[]; // parent properties a05_SubContinent_ReChild.Parent_SubContinent_ID = dr.GetInt32("SubContinent_ID2"); return(a05_SubContinent_ReChild); }
/// <summary> /// Inserts a new A05_SubContinent_ReChild object in the database. /// </summary> /// <param name="a05_SubContinent_ReChild">The A05 Sub Continent Re Child DTO.</param> /// <returns>The new <see cref="A05_SubContinent_ReChildDto"/>.</returns> public A05_SubContinent_ReChildDto Insert(A05_SubContinent_ReChildDto a05_SubContinent_ReChild) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddA05_SubContinent_ReChild", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID2", a05_SubContinent_ReChild.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Child_Name", a05_SubContinent_ReChild.SubContinent_Child_Name).DbType = DbType.String; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); a05_SubContinent_ReChild.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(a05_SubContinent_ReChild); }
/// <summary> /// Updates in the database all changes made to the A05_SubContinent_ReChild object. /// </summary> /// <param name="a05_SubContinent_ReChild">The A05 Sub Continent Re Child DTO.</param> /// <returns>The updated <see cref="A05_SubContinent_ReChildDto"/>.</returns> public A05_SubContinent_ReChildDto Update(A05_SubContinent_ReChildDto a05_SubContinent_ReChild) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateA05_SubContinent_ReChild", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID2", a05_SubContinent_ReChild.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Child_Name", a05_SubContinent_ReChild.SubContinent_Child_Name).DbType = DbType.String; cmd.Parameters.AddWithValue("@RowVersion", a05_SubContinent_ReChild.RowVersion).DbType = DbType.Binary; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("A05_SubContinent_ReChild"); } a05_SubContinent_ReChild.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(a05_SubContinent_ReChild); }