/// <summary> /// Factory method. Loads a <see cref="E11_City_Child"/> object from the given E11_City_ChildDto. /// </summary> /// <param name="data">The <see cref="E11_City_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="E11_City_Child"/> object.</returns> internal static E11_City_Child GetE11_City_Child(E11_City_ChildDto data) { E11_City_Child obj = new E11_City_Child(); obj.Fetch(data); return(obj); }
/// <summary> /// Loads a <see cref="E11_City_Child"/> object from the given <see cref="E11_City_ChildDto"/>. /// </summary> /// <param name="data">The E11_City_ChildDto to use.</param> private void Fetch(E11_City_ChildDto data) { // Value properties City_Child_Name = data.City_Child_Name; // parent properties city_ID1 = data.Parent_City_ID; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
/// <summary> /// Factory method. Loads a <see cref="E11_City_Child"/> object from the given E11_City_ChildDto. /// </summary> /// <param name="data">The <see cref="E11_City_ChildDto"/>.</param> /// <returns>A reference to the fetched <see cref="E11_City_Child"/> object.</returns> internal static E11_City_Child GetE11_City_Child(E11_City_ChildDto data) { E11_City_Child obj = new E11_City_Child(); // show the framework that this is a child object obj.MarkAsChild(); obj.Fetch(data); obj.MarkOld(); return(obj); }
private E11_City_ChildDto FetchE11_City_Child(SafeDataReader dr) { var e11_City_Child = new E11_City_ChildDto(); // Value properties e11_City_Child.City_Child_Name = dr.GetString("City_Child_Name"); // parent properties e11_City_Child.Parent_City_ID = dr.GetInt32("City_ID1"); return(e11_City_Child); }
/// <summary> /// Inserts a new E11_City_Child object in the database. /// </summary> /// <param name="e11_City_Child">The E11 City Child DTO.</param> /// <returns>The new <see cref="E11_City_ChildDto"/>.</returns> public E11_City_ChildDto Insert(E11_City_ChildDto e11_City_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("AddE11_City_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@City_ID1", e11_City_Child.Parent_City_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@City_Child_Name", e11_City_Child.City_Child_Name).DbType = DbType.String; cmd.ExecuteNonQuery(); } } return(e11_City_Child); }
/// <summary> /// Updates in the database all changes made to the E11_City_Child object. /// </summary> /// <param name="e11_City_Child">The E11 City Child DTO.</param> /// <returns>The updated <see cref="E11_City_ChildDto"/>.</returns> public E11_City_ChildDto Update(E11_City_ChildDto e11_City_Child) { using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad")) { using (var cmd = new SqlCommand("UpdateE11_City_Child", ctx.Connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@City_ID1", e11_City_Child.Parent_City_ID).DbType = DbType.Int32; cmd.Parameters.AddWithValue("@City_Child_Name", e11_City_Child.City_Child_Name).DbType = DbType.String; var rowsAffected = cmd.ExecuteNonQuery(); if (rowsAffected == 0) { throw new DataNotFoundException("E11_City_Child"); } } } return(e11_City_Child); }
private void Child_Insert(E10_City parent) { var dto = new E11_City_ChildDto(); dto.Parent_City_ID = parent.City_ID; dto.City_Child_Name = City_Child_Name; using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager()) { var args = new DataPortalHookArgs(dto); OnInsertPre(args); var dal = dalManager.GetProvider <IE11_City_ChildDal>(); using (BypassPropertyChecks) { var resultDto = dal.Insert(dto); args = new DataPortalHookArgs(resultDto); } OnInsertPost(args); } }