Пример #1
0
        private void Child_Update()
        {
            if (!IsDirty)
            {
                return;
            }

            var dto = new B08_RegionDto();

            dto.Region_ID   = Region_ID;
            dto.Region_Name = Region_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IB08_RegionDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }
Пример #2
0
        /// <summary>
        /// Factory method. Loads a <see cref="B08_Region"/> object from the given B08_RegionDto.
        /// </summary>
        /// <param name="data">The <see cref="B08_RegionDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="B08_Region"/> object.</returns>
        internal static B08_Region GetB08_Region(B08_RegionDto data)
        {
            B08_Region obj = new B08_Region();

            obj.Fetch(data);
            obj.LoadProperty(B09_CityObjectsProperty, new B09_CityColl());
            return(obj);
        }
Пример #3
0
        /// <summary>
        /// Loads a <see cref="B08_Region"/> object from the given <see cref="B08_RegionDto"/>.
        /// </summary>
        /// <param name="data">The B08_RegionDto to use.</param>
        private void Fetch(B08_RegionDto data)
        {
            // Value properties
            LoadProperty(Region_IDProperty, data.Region_ID);
            LoadProperty(Region_NameProperty, data.Region_Name);
            // parent properties
            parent_Country_ID = data.Parent_Country_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Пример #4
0
        /// <summary>
        /// Factory method. Loads a <see cref="B08_Region"/> object from the given B08_RegionDto.
        /// </summary>
        /// <param name="data">The <see cref="B08_RegionDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="B08_Region"/> object.</returns>
        internal static B08_Region GetB08_Region(B08_RegionDto data)
        {
            B08_Region obj = new B08_Region();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.LoadProperty(B09_CityObjectsProperty, B09_CityColl.NewB09_CityColl());
            obj.MarkOld();
            return(obj);
        }
Пример #5
0
        private B08_RegionDto FetchB08_Region(SafeDataReader dr)
        {
            var b08_Region = new B08_RegionDto();

            // Value properties
            b08_Region.Region_ID   = dr.GetInt32("Region_ID");
            b08_Region.Region_Name = dr.GetString("Region_Name");
            // parent properties
            b08_Region.Parent_Country_ID = dr.GetInt32("Parent_Country_ID");

            return(b08_Region);
        }
 /// <summary>
 /// Inserts a new B08_Region object in the database.
 /// </summary>
 /// <param name="b08_Region">The B08 Region DTO.</param>
 /// <returns>The new <see cref="B08_RegionDto"/>.</returns>
 public B08_RegionDto Insert(B08_RegionDto b08_Region)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddB08_Region", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Parent_Country_ID", b08_Region.Parent_Country_ID).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_ID", b08_Region.Region_ID).Direction  = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@Region_Name", b08_Region.Region_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
             b08_Region.Region_ID = (int)cmd.Parameters["@Region_ID"].Value;
         }
     }
     return(b08_Region);
 }
 /// <summary>
 /// Updates in the database all changes made to the B08_Region object.
 /// </summary>
 /// <param name="b08_Region">The B08 Region DTO.</param>
 /// <returns>The updated <see cref="B08_RegionDto"/>.</returns>
 public B08_RegionDto Update(B08_RegionDto b08_Region)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateB08_Region", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Region_ID", b08_Region.Region_ID).DbType     = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_Name", b08_Region.Region_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("B08_Region");
             }
         }
     }
     return(b08_Region);
 }
Пример #8
0
        private void Child_Insert(B06_Country parent)
        {
            var dto = new B08_RegionDto();

            dto.Parent_Country_ID = parent.Country_ID;
            dto.Region_Name       = Region_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IB08_RegionDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(Region_IDProperty, resultDto.Region_ID);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }