/// <summary>
        /// Updates a MapAttachmentLayer record and returns the number of records affected
        /// </summary>
        public static int Update(MapAttachmentLayerDO DO)
        {
            SqlParameter _MapAttachmentID = new SqlParameter("MapAttachmentID", SqlDbType.Int);
            SqlParameter _LayerID = new SqlParameter("LayerID", SqlDbType.VarChar);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            
            _MapAttachmentID.Value = DO.MapAttachmentID;
            _LayerID.Value = DO.LayerID;
            _PermitKey.Value = DO.PermitKey;
            
            SqlParameter[] _params = new SqlParameter[] {
                _MapAttachmentID,
                _LayerID,
                _PermitKey
            };

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

            return DataCommon.ExecuteScalar("[dbo].[MapAttachmentLayer_Update]", _params, pid);
        }
        /// <summary>
        /// Creates a new MapAttachmentLayer record using async
        /// </summary>
        public static async Task CreateAsync(MapAttachmentLayerDO DO)
        {
            SqlParameter _MapAttachmentID = new SqlParameter("MapAttachmentID", SqlDbType.Int);
            SqlParameter _LayerID = new SqlParameter("LayerID", SqlDbType.VarChar);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            
            _MapAttachmentID.Value = DO.MapAttachmentID;
            _LayerID.Value = DO.LayerID;
            _PermitKey.Value = DO.PermitKey;
            
            SqlParameter[] _params = new SqlParameter[] {
                _MapAttachmentID,
                _LayerID,
                _PermitKey
            };

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

            await DataCommon.ExecuteNonQueryAsync("[dbo].[MapAttachmentLayer_Insert]", _params, pid);
            
        }
        /// <summary>
        /// Selects MapAttachmentLayer records by PK
        /// </summary>
        public static async Task<MapAttachmentLayerDO[]> GetByPKAsync(Int32 MapAttachmentID,
 String LayerID)
        {

            SqlParameter _MapAttachmentID = new SqlParameter("MapAttachmentID", SqlDbType.Int);
            SqlParameter _LayerID = new SqlParameter("LayerID", SqlDbType.VarChar);
			
            _MapAttachmentID.Value = MapAttachmentID;
            _LayerID.Value = LayerID;
			
            SqlParameter[] _params = new SqlParameter[] {
                _MapAttachmentID,
                _LayerID
            };

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

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


            List<MapAttachmentLayerDO> objs = new List<MapAttachmentLayerDO>();
			
            while(sr.Read())
            {
                MapAttachmentLayerDO obj = new MapAttachmentLayerDO();
				
                obj.MapAttachmentID = sr.GetInt32(sr.GetOrdinal("MapAttachmentID"));
                obj.LayerID = sr.GetString(sr.GetOrdinal("LayerID"));
                if (sr.IsDBNull(sr.GetOrdinal("PermitKey"))) { obj.PermitKey = null; } else { obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey")); }

                objs.Add(obj);
            }

            return objs.ToArray();
        }
/// <summary>
        /// Selects MapAttachmentLayer records by PermitKey
        /// </summary>
        public static MapAttachmentLayerDO[] GetByPermitKey(Int32 PermitKey)
        {

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

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

            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[MapAttachmentLayer_GetByPermitKey]", _params, pid);


            List<MapAttachmentLayerDO> objs = new List<MapAttachmentLayerDO>();
			
            while(sr.Read())
            {
                MapAttachmentLayerDO obj = new MapAttachmentLayerDO();
				
                obj.MapAttachmentID = sr.GetInt32(sr.GetOrdinal("MapAttachmentID"));
                obj.LayerID = sr.GetString(sr.GetOrdinal("LayerID"));
                if (sr.IsDBNull(sr.GetOrdinal("PermitKey"))) { obj.PermitKey = null; } else { obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey")); }

                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Gets all MapAttachmentLayer records
        /// </summary>
        public static async Task<MapAttachmentLayerDO[]> GetAllAsync()
        {

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

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

                MapAttachmentLayerDO obj = new MapAttachmentLayerDO();
                
                obj.MapAttachmentID = sr.GetInt32(sr.GetOrdinal("MapAttachmentID"));
                obj.LayerID = sr.GetString(sr.GetOrdinal("LayerID"));
                if (sr.IsDBNull(sr.GetOrdinal("PermitKey"))) { obj.PermitKey = null; } else { obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey")); }


                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Deletes a MapAttachmentLayer record
        /// </summary>
        public static async Task<int> DeleteAsync(MapAttachmentLayerDO DO)
        {
            SqlParameter _MapAttachmentID = new SqlParameter("MapAttachmentID", SqlDbType.Int);
            SqlParameter _LayerID = new SqlParameter("LayerID", SqlDbType.VarChar);
            
            _MapAttachmentID.Value = DO.MapAttachmentID;
            _LayerID.Value = DO.LayerID;
            
            SqlParameter[] _params = new SqlParameter[] {
                _MapAttachmentID,
                _LayerID
            };

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

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