/// <summary> /// Factory method. Loads a <see cref="A05_SubContinent_Child"/> object from the given A05_SubContinent_ChildDto. /// </summary> /// <param name="data">The <see cref="A05_SubContinent_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="A05_SubContinent_Child"/> object.</returns> internal static A05_SubContinent_Child GetA05_SubContinent_Child(A05_SubContinent_ChildDto data) { A05_SubContinent_Child obj = new A05_SubContinent_Child(); obj.Fetch(data); return(obj); }
private void Child_Update(A04_SubContinent parent) { if (!IsDirty) { return; } var dto = new A05_SubContinent_ChildDto(); 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_ChildDal>(); 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_Child"/> object from the given A05_SubContinent_ChildDto. /// </summary> /// <param name="data">The <see cref="A05_SubContinent_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="A05_SubContinent_Child"/> object.</returns> internal static A05_SubContinent_Child GetA05_SubContinent_Child(A05_SubContinent_ChildDto data) { A05_SubContinent_Child obj = new A05_SubContinent_Child(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); return(obj); }
/// <summary> /// Loads a <see cref="A05_SubContinent_Child"/> object from the given <see cref="A05_SubContinent_ChildDto"/>. /// </summary> /// <param name="data">The A05_SubContinent_ChildDto to use.</param> private void Fetch(A05_SubContinent_ChildDto data) { // Value properties LoadProperty(SubContinent_Child_NameProperty, data.SubContinent_Child_Name); _rowVersion = data.RowVersion; // parent properties subContinent_ID1 = data.Parent_SubContinent_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private A05_SubContinent_ChildDto FetchA05_SubContinent_Child(SafeDataReader dr) { var a05_SubContinent_Child = new A05_SubContinent_ChildDto(); // Value properties a05_SubContinent_Child.SubContinent_Child_Name = dr.GetString("SubContinent_Child_Name"); a05_SubContinent_Child.RowVersion = dr.GetValue("RowVersion") as byte[]; // parent properties a05_SubContinent_Child.Parent_SubContinent_ID = dr.GetInt32("SubContinent_ID1"); return(a05_SubContinent_Child); }
/// <summary> /// Inserts a new A05_SubContinent_Child object in the database. /// </summary> /// <param name="a05_SubContinent_Child">The A05 Sub Continent Child DTO.</param> /// <returns>The new <see cref="A05_SubContinent_ChildDto"/>.</returns> public A05_SubContinent_ChildDto Insert(A05_SubContinent_ChildDto a05_SubContinent_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddA05_SubContinent_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID1", a05_SubContinent_Child.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Child_Name", a05_SubContinent_Child.SubContinent_Child_Name).DbType = DbType.String; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); a05_SubContinent_Child.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(a05_SubContinent_Child); }
/// <summary> /// Updates in the database all changes made to the A05_SubContinent_Child object. /// </summary> /// <param name="a05_SubContinent_Child">The A05 Sub Continent Child DTO.</param> /// <returns>The updated <see cref="A05_SubContinent_ChildDto"/>.</returns> public A05_SubContinent_ChildDto Update(A05_SubContinent_ChildDto a05_SubContinent_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateA05_SubContinent_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SubContinent_ID1", a05_SubContinent_Child.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@SubContinent_Child_Name", a05_SubContinent_Child.SubContinent_Child_Name).DbType = DbType.String; cmd.Parameters.AddWithValue("@RowVersion", a05_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("A05_SubContinent_Child"); } a05_SubContinent_Child.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(a05_SubContinent_Child); }