/// <summary> /// Factory method. Loads a <see cref="A07_Country_Child"/> object from the given A07_Country_ChildDto. /// </summary> /// <param name="data">The <see cref="A07_Country_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="A07_Country_Child"/> object.</returns> internal static A07_Country_Child GetA07_Country_Child(A07_Country_ChildDto data) { A07_Country_Child obj = new A07_Country_Child(); obj.Fetch(data); return(obj); }
/// <summary> /// Loads a <see cref="A07_Country_Child"/> object from the given <see cref="A07_Country_ChildDto"/>. /// </summary> /// <param name="data">The A07_Country_ChildDto to use.</param> private void Fetch(A07_Country_ChildDto data) { // Value properties LoadProperty(Country_Child_NameProperty, data.Country_Child_Name); // parent properties country_ID1 = data.Parent_Country_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
/// <summary> /// Factory method. Loads a <see cref="A07_Country_Child"/> object from the given A07_Country_ChildDto. /// </summary> /// <param name="data">The <see cref="A07_Country_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="A07_Country_Child"/> object.</returns> internal static A07_Country_Child GetA07_Country_Child(A07_Country_ChildDto data) { A07_Country_Child obj = new A07_Country_Child(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); return(obj); }
private A07_Country_ChildDto FetchA07_Country_Child(SafeDataReader dr) { var a07_Country_Child = new A07_Country_ChildDto(); // Value properties a07_Country_Child.Country_Child_Name = dr.GetString("Country_Child_Name"); // parent properties a07_Country_Child.Parent_Country_ID = dr.GetInt32("Country_ID1"); return(a07_Country_Child); }
/// <summary> /// Inserts a new A07_Country_Child object in the database. /// </summary> /// <param name="a07_Country_Child">The A07 Country Child DTO.</param> /// <returns>The new <see cref="A07_Country_ChildDto"/>.</returns> public A07_Country_ChildDto Insert(A07_Country_ChildDto a07_Country_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddA07_Country_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Country_ID1", a07_Country_Child.Parent_Country_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Country_Child_Name", a07_Country_Child.Country_Child_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); } } return(a07_Country_Child); }
/// <summary> /// Updates in the database all changes made to the A07_Country_Child object. /// </summary> /// <param name="a07_Country_Child">The A07 Country Child DTO.</param> /// <returns>The updated <see cref="A07_Country_ChildDto"/>.</returns> public A07_Country_ChildDto Update(A07_Country_ChildDto a07_Country_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateA07_Country_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Country_ID1", a07_Country_Child.Parent_Country_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@Country_Child_Name", a07_Country_Child.Country_Child_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("A07_Country_Child"); } } } return(a07_Country_Child); }
private void Child_Insert(A06_Country parent) { var dto = new A07_Country_ChildDto(); dto.Parent_Country_ID = parent.Country_ID; dto.Country_Child_Name = Country_Child_Name; using (var dalManager = DalFactoryParentLoad.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IA07_Country_ChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); } }