/// <summary>
        /// Updates a AttachmentType record and returns the number of records affected
        /// </summary>
        public static int Update(AttachmentTypeDO DO)
        {
            SqlParameter _AttachmentTypeID = new SqlParameter("AttachmentTypeID", SqlDbType.Int);
            SqlParameter _Description = new SqlParameter("Description", SqlDbType.VarChar);
            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            
            _AttachmentTypeID.Value = DO.AttachmentTypeID;
            _Description.Value = DO.Description;
            _TOCID.Value = DO.TOCID;
            
            SqlParameter[] _params = new SqlParameter[] {
                _AttachmentTypeID,
                _Description,
                _TOCID
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return DataCommon.ExecuteScalar("[dbo].[AttachmentType_Update]", _params, pid);
        }
        /// <summary>
        /// Creates a new AttachmentType record using async
        /// </summary>
        public static async Task CreateAsync(AttachmentTypeDO DO)
        {
            SqlParameter _AttachmentTypeID = new SqlParameter("AttachmentTypeID", SqlDbType.Int);
            SqlParameter _Description = new SqlParameter("Description", SqlDbType.VarChar);
            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            
            _AttachmentTypeID.Value = DO.AttachmentTypeID;
            _Description.Value = DO.Description;
            _TOCID.Value = DO.TOCID;
            
            SqlParameter[] _params = new SqlParameter[] {
                _AttachmentTypeID,
                _Description,
                _TOCID
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            await DataCommon.ExecuteNonQueryAsync("[dbo].[AttachmentType_Insert]", _params, pid);
            
        }
        /// <summary>
        /// Gets all AttachmentType records
        /// </summary>
        public static async Task<AttachmentTypeDO[]> GetAllAsync()
        {

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[AttachmentType_GetAll]", new SqlParameter[] { }, pid);
            
            List<AttachmentTypeDO> objs = new List<AttachmentTypeDO>();
            
            while(sr.Read()){

                AttachmentTypeDO obj = new AttachmentTypeDO();
                
                obj.AttachmentTypeID = sr.GetInt32(sr.GetOrdinal("AttachmentTypeID"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                


                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Selects AttachmentType records by PK
        /// </summary>
        public static async Task<AttachmentTypeDO[]> GetByPKAsync(Int32 AttachmentTypeID)
        {

            SqlParameter _AttachmentTypeID = new SqlParameter("AttachmentTypeID", SqlDbType.Int);
			
            _AttachmentTypeID.Value = AttachmentTypeID;
			
            SqlParameter[] _params = new SqlParameter[] {
                _AttachmentTypeID
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[AttachmentType_GetByPK]", _params, pid);


            List<AttachmentTypeDO> objs = new List<AttachmentTypeDO>();
			
            while(sr.Read())
            {
                AttachmentTypeDO obj = new AttachmentTypeDO();
				
                obj.AttachmentTypeID = sr.GetInt32(sr.GetOrdinal("AttachmentTypeID"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                

                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Deletes a AttachmentType record
        /// </summary>
        public static async Task<int> DeleteAsync(AttachmentTypeDO DO)
        {
            SqlParameter _AttachmentTypeID = new SqlParameter("AttachmentTypeID", SqlDbType.Int);
            
            _AttachmentTypeID.Value = DO.AttachmentTypeID;
            
            SqlParameter[] _params = new SqlParameter[] {
                _AttachmentTypeID
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return await DataCommon.ExecuteScalarAsync("[dbo].[AttachmentType_Delete]", _params, pid);
        }