Example #1
0
        private void Child_Update()
        {
            if (!IsDirty)
            {
                return;
            }

            var dto = new B06_CountryDto();

            dto.Country_ID   = Country_ID;
            dto.Country_Name = Country_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IB06_CountryDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }
Example #2
0
        /// <summary>
        /// Factory method. Loads a <see cref="B06_Country"/> object from the given B06_CountryDto.
        /// </summary>
        /// <param name="data">The <see cref="B06_CountryDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="B06_Country"/> object.</returns>
        internal static B06_Country GetB06_Country(B06_CountryDto data)
        {
            B06_Country obj = new B06_Country();

            obj.Fetch(data);
            obj.LoadProperty(B07_RegionObjectsProperty, new B07_RegionColl());
            return(obj);
        }
Example #3
0
        /// <summary>
        /// Loads a <see cref="B06_Country"/> object from the given <see cref="B06_CountryDto"/>.
        /// </summary>
        /// <param name="data">The B06_CountryDto to use.</param>
        private void Fetch(B06_CountryDto data)
        {
            // Value properties
            LoadProperty(Country_IDProperty, data.Country_ID);
            LoadProperty(Country_NameProperty, data.Country_Name);
            // parent properties
            parent_SubContinent_ID = data.Parent_SubContinent_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Example #4
0
        /// <summary>
        /// Factory method. Loads a <see cref="B06_Country"/> object from the given B06_CountryDto.
        /// </summary>
        /// <param name="data">The <see cref="B06_CountryDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="B06_Country"/> object.</returns>
        internal static B06_Country GetB06_Country(B06_CountryDto data)
        {
            B06_Country obj = new B06_Country();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.LoadProperty(B07_RegionObjectsProperty, B07_RegionColl.NewB07_RegionColl());
            obj.MarkOld();
            return(obj);
        }
Example #5
0
        private B06_CountryDto FetchB06_Country(SafeDataReader dr)
        {
            var b06_Country = new B06_CountryDto();

            // Value properties
            b06_Country.Country_ID   = dr.GetInt32("Country_ID");
            b06_Country.Country_Name = dr.GetString("Country_Name");
            // parent properties
            b06_Country.Parent_SubContinent_ID = dr.GetInt32("Parent_SubContinent_ID");

            return(b06_Country);
        }
Example #6
0
 /// <summary>
 /// Inserts a new B06_Country object in the database.
 /// </summary>
 /// <param name="b06_Country">The B06 Country DTO.</param>
 /// <returns>The new <see cref="B06_CountryDto"/>.</returns>
 public B06_CountryDto Insert(B06_CountryDto b06_Country)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddB06_Country", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Parent_SubContinent_ID", b06_Country.Parent_SubContinent_ID).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_ID", b06_Country.Country_ID).Direction  = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@Country_Name", b06_Country.Country_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
             b06_Country.Country_ID = (int)cmd.Parameters["@Country_ID"].Value;
         }
     }
     return(b06_Country);
 }
Example #7
0
 /// <summary>
 /// Updates in the database all changes made to the B06_Country object.
 /// </summary>
 /// <param name="b06_Country">The B06 Country DTO.</param>
 /// <returns>The updated <see cref="B06_CountryDto"/>.</returns>
 public B06_CountryDto Update(B06_CountryDto b06_Country)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateB06_Country", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Country_ID", b06_Country.Country_ID).DbType     = DbType.Int32;
             cmd.Parameters.AddWithValue("@Country_Name", b06_Country.Country_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("B06_Country");
             }
         }
     }
     return(b06_Country);
 }
Example #8
0
        private void Child_Insert(B04_SubContinent parent)
        {
            var dto = new B06_CountryDto();

            dto.Parent_SubContinent_ID = parent.SubContinent_ID;
            dto.Country_Name           = Country_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IB06_CountryDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(Country_IDProperty, resultDto.Country_ID);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }