private void Child_Update() { if (!IsDirty) { return; } var dto = new E06_CountryDto(); dto.Country_ID = Country_ID; dto.Country_Name = Country_Name; dto.ParentSubContinentID = ParentSubContinentID; dto.RowVersion = _rowVersion; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnUpdatePre(args); var dal = dalManager.GetProvider <IE06_CountryDal>(); using (BypassPropertyChecks) { var resultDto = dal.Update(dto); _rowVersion = resultDto.RowVersion; args = new DataPortalHookArgs(resultDto); } OnUpdatePost(args); // flushes all pending data operations FieldManager.UpdateChildren(this); } }
/// <summary> /// Factory method. Loads a <see cref="E06_Country"/> object from the given E06_CountryDto. /// </summary> /// <param name="data">The <see cref="E06_CountryDto"/>.</param> /// <returns>A reference to the fetched <see cref="E06_Country"/> object.</returns> internal static E06_Country GetE06_Country(E06_CountryDto data) { E06_Country obj = new E06_Country(); obj.Fetch(data); obj.LoadProperty(E07_RegionObjectsProperty, new E07_RegionColl()); return(obj); }
/// <summary> /// Factory method. Loads a <see cref="E06_Country"/> object from the given E06_CountryDto. /// </summary> /// <param name="data">The <see cref="E06_CountryDto"/>.</param> /// <returns>A reference to the fetched <see cref="E06_Country"/> object.</returns> internal static E06_Country GetE06_Country(E06_CountryDto data) { E06_Country obj = new E06_Country(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.LoadProperty(E07_RegionObjectsProperty, E07_RegionColl.NewE07_RegionColl()); obj.MarkOld(); return(obj); }
/// <summary> /// Loads a <see cref="E06_Country"/> object from the given <see cref="E06_CountryDto"/>. /// </summary> /// <param name="data">The E06_CountryDto to use.</param> private void Fetch(E06_CountryDto data) { // Value properties LoadProperty(Country_IDProperty, data.Country_ID); LoadProperty(Country_NameProperty, data.Country_Name); LoadProperty(ParentSubContinentIDProperty, data.ParentSubContinentID); _rowVersion = data.RowVersion; // parent properties parent_SubContinent_ID = data.Parent_SubContinent_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
private E06_CountryDto FetchE06_Country(SafeDataReader dr) { var e06_Country = new E06_CountryDto(); // Value properties e06_Country.Country_ID = dr.GetInt32("Country_ID"); e06_Country.Country_Name = dr.GetString("Country_Name"); e06_Country.ParentSubContinentID = dr.GetInt32("Parent_SubContinent_ID"); e06_Country.RowVersion = dr.GetValue("RowVersion") as byte[]; // parent properties e06_Country.Parent_SubContinent_ID = dr.GetInt32("Parent_SubContinent_ID"); return(e06_Country); }
/// <summary> /// Inserts a new E06_Country object in the database. /// </summary> /// <param name="e06_Country">The E06 Country DTO.</param> /// <returns>The new <see cref="E06_CountryDto"/>.</returns> public E06_CountryDto Insert(E06_CountryDto e06_Country) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddE06_Country", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Parent_SubContinent_ID", e06_Country.Parent_SubContinent_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Country_ID", e06_Country.Country_ID).Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@Country_Name", e06_Country.Country_Name).DbType = DbType.String; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); e06_Country.Country_ID = (int)cmd.Parameters["@Country_ID"].Value; e06_Country.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(e06_Country); }
/// <summary> /// Updates in the database all changes made to the E06_Country object. /// </summary> /// <param name="e06_Country">The E06 Country DTO.</param> /// <returns>The updated <see cref="E06_CountryDto"/>.</returns> public E06_CountryDto Update(E06_CountryDto e06_Country) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateE06_Country", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Country_ID", e06_Country.Country_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Country_Name", e06_Country.Country_Name).DbType = DbType.String; cmd.Parameters.AddWithValue("@Parent_SubContinent_ID", e06_Country.ParentSubContinentID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@RowVersion", e06_Country.RowVersion).DbType = DbType.Binary; cmd.Parameters.Add("@NewRowVersion", SqlDbType.Timestamp).Direction = ParameterDirection.Output; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("E06_Country"); } e06_Country.RowVersion = (byte[])cmd.Parameters["@NewRowVersion"].Value; } } return(e06_Country); }
private void Child_Insert(E04_SubContinent parent) { var dto = new E06_CountryDto(); dto.Parent_SubContinent_ID = parent.SubContinent_ID; dto.Country_Name = Country_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IE06_CountryDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); LoadProperty(Country_IDProperty, resultDto.Country_ID); _rowVersion = resultDto.RowVersion; args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); // flushes all pending data operations FieldManager.UpdateChildren(this); } }