/// <summary>
        /// Creates a new ActivityLog record using async
        /// </summary>
        public static async Task<int> CreateAsync(ActivityLogDO DO)
        {
            SqlParameter _ActivityLogDate = new SqlParameter("ActivityLogDate", SqlDbType.DateTime);
            SqlParameter _Description = new SqlParameter("Description", SqlDbType.VarChar);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            
            _ActivityLogDate.Value = DO.ActivityLogDate;
            _Description.Value = DO.Description;
            _PermitKey.Value = DO.PermitKey;
            
            SqlParameter[] _params = new SqlParameter[] {
                _ActivityLogDate,
                _Description,
                _PermitKey
            };

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

            return await DataCommon.ExecuteScalarAsync("[dbo].[ActivityLog_Insert]", _params, pid);
            
        }
        /// <summary>
        /// Updates a ActivityLog record and returns the number of records affected
        /// </summary>
        public static int Update(ActivityLogDO DO)
        {
            SqlParameter _ActivityLogID = new SqlParameter("ActivityLogID", SqlDbType.Int);
            SqlParameter _ActivityLogDate = new SqlParameter("ActivityLogDate", SqlDbType.DateTime);
            SqlParameter _Description = new SqlParameter("Description", SqlDbType.VarChar);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            
            _ActivityLogID.Value = DO.ActivityLogID;
            _ActivityLogDate.Value = DO.ActivityLogDate;
            _Description.Value = DO.Description;
            _PermitKey.Value = DO.PermitKey;
            
            SqlParameter[] _params = new SqlParameter[] {
                _ActivityLogID,
                _ActivityLogDate,
                _Description,
                _PermitKey
            };

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

            return DataCommon.ExecuteScalar("[dbo].[ActivityLog_Update]", _params, pid);
        }
        /// <summary>
        /// Gets all ActivityLog records
        /// </summary>
        public static ActivityLogDO[] GetAll()
        {

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

            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[ActivityLog_GetAll]", new SqlParameter[] { }, pid);
            
            List<ActivityLogDO> objs = new List<ActivityLogDO>();
            
            while(sr.Read()){

                ActivityLogDO obj = new ActivityLogDO();
                
                obj.ActivityLogID = sr.GetInt32(sr.GetOrdinal("ActivityLogID"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                if (sr.IsDBNull(sr.GetOrdinal("ActivityLogDate"))) { obj.ActivityLogDate = null; } else { obj.ActivityLogDate = sr.GetDateTime(sr.GetOrdinal("ActivityLogDate")); }


                objs.Add(obj);
            }

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

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

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

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


            List<ActivityLogDO> objs = new List<ActivityLogDO>();
			
            while(sr.Read())
            {
                ActivityLogDO obj = new ActivityLogDO();
				
                obj.ActivityLogID = sr.GetInt32(sr.GetOrdinal("ActivityLogID"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                if (sr.IsDBNull(sr.GetOrdinal("ActivityLogDate"))) { obj.ActivityLogDate = null; } else { obj.ActivityLogDate = sr.GetDateTime(sr.GetOrdinal("ActivityLogDate")); }

                objs.Add(obj);
            }

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

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

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