/// <summary>
 /// Inserts a new E12_CityRoad object in the database.
 /// </summary>
 /// <param name="e12_CityRoad">The E12 City Road DTO.</param>
 /// <returns>The new <see cref="E12_CityRoadDto"/>.</returns>
 public E12_CityRoadDto Insert(E12_CityRoadDto e12_CityRoad)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddE12_CityRoad", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Parent_City_ID", e12_CityRoad.Parent_City_ID).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@CityRoad_ID", e12_CityRoad.CityRoad_ID).Direction    = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@CityRoad_Name", e12_CityRoad.CityRoad_Name).DbType   = DbType.String;
             cmd.ExecuteNonQuery();
             e12_CityRoad.CityRoad_ID = (int)cmd.Parameters["@CityRoad_ID"].Value;
         }
     }
     return(e12_CityRoad);
 }
 /// <summary>
 /// Updates in the database all changes made to the E12_CityRoad object.
 /// </summary>
 /// <param name="e12_CityRoad">The E12 City Road DTO.</param>
 /// <returns>The updated <see cref="E12_CityRoadDto"/>.</returns>
 public E12_CityRoadDto Update(E12_CityRoadDto e12_CityRoad)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateE12_CityRoad", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@CityRoad_ID", e12_CityRoad.CityRoad_ID).DbType     = DbType.Int32;
             cmd.Parameters.AddWithValue("@CityRoad_Name", e12_CityRoad.CityRoad_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("E12_CityRoad");
             }
         }
     }
     return(e12_CityRoad);
 }
        private void Child_Insert(E10_City parent)
        {
            var dto = new E12_CityRoadDto();

            dto.Parent_City_ID = parent.City_ID;
            dto.CityRoad_Name  = CityRoad_Name;
            using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IE12_CityRoadDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(CityRoad_IDProperty, resultDto.CityRoad_ID);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
            }
        }
        private void Child_Update()
        {
            if (!IsDirty)
            {
                return;
            }

            var dto = new E12_CityRoadDto();

            dto.CityRoad_ID   = CityRoad_ID;
            dto.CityRoad_Name = CityRoad_Name;
            using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IE12_CityRoadDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
            }
        }