/// <summary>
        /// Updates a AttachmentContent record and returns the number of records affected
        /// </summary>
        public static int Update(AttachmentContentDO DO)
        {
            SqlParameter _AttachmentID = new SqlParameter("AttachmentID", SqlDbType.Int);
            SqlParameter _Content = new SqlParameter("Content", SqlDbType.VarBinary);
            
            _AttachmentID.Value = DO.AttachmentID;
            _Content.Value = DO.Content;
            
            SqlParameter[] _params = new SqlParameter[] {
                _AttachmentID,
                _Content
            };

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

            return DataCommon.ExecuteScalar("[dbo].[AttachmentContent_Update]", _params, pid);
        }
        /// <summary>
        /// Creates a new AttachmentContent record using async
        /// </summary>
        public static async Task CreateAsync(AttachmentContentDO DO)
        {
            SqlParameter _AttachmentID = new SqlParameter("AttachmentID", SqlDbType.Int);
            SqlParameter _Content = new SqlParameter("Content", SqlDbType.VarBinary);
            
            _AttachmentID.Value = DO.AttachmentID;
            _Content.Value = DO.Content;
            
            SqlParameter[] _params = new SqlParameter[] {
                _AttachmentID,
                _Content
            };

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

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

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

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

                AttachmentContentDO obj = new AttachmentContentDO();
                
                obj.AttachmentID = sr.GetInt32(sr.GetOrdinal("AttachmentID"));
                obj.Content = sr.GetBytes(sr.GetOrdinal("Content"));
                


                objs.Add(obj);
            }

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

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

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

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


            List<AttachmentContentDO> objs = new List<AttachmentContentDO>();
			
            while(sr.Read())
            {
                AttachmentContentDO obj = new AttachmentContentDO();
				
                obj.AttachmentID = sr.GetInt32(sr.GetOrdinal("AttachmentID"));
                obj.Content = sr.GetBytes(sr.GetOrdinal("Content"));
                

                objs.Add(obj);
            }

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

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

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