/// <summary>
        /// Creates a new PermitTableFieldReference record using async
        /// </summary>
        public static async Task CreateAsync(PermitTableFieldReferenceDO DO)
        {
            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            SqlParameter _Label = new SqlParameter("Label", SqlDbType.VarChar);
            SqlParameter _FieldType = new SqlParameter("FieldType", SqlDbType.VarChar);
            SqlParameter _FieldNAme = new SqlParameter("FieldNAme", SqlDbType.VarChar);
            
            _TOCID.Value = DO.TOCID;
            _Label.Value = DO.Label;
            _FieldType.Value = DO.FieldType;
            _FieldNAme.Value = DO.FieldNAme;
            
            SqlParameter[] _params = new SqlParameter[] {
                _TOCID,
                _Label,
                _FieldType,
                _FieldNAme
            };

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

            await DataCommon.ExecuteNonQueryAsync("[dbo].[PermitTableFieldReference_Insert]", _params, pid);
            
        }
        /// <summary>
        /// Updates a PermitTableFieldReference record and returns the number of records affected
        /// </summary>
        public static int Update(PermitTableFieldReferenceDO DO)
        {
            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            SqlParameter _Label = new SqlParameter("Label", SqlDbType.VarChar);
            SqlParameter _FieldType = new SqlParameter("FieldType", SqlDbType.VarChar);
            SqlParameter _FieldNAme = new SqlParameter("FieldNAme", SqlDbType.VarChar);
            
            _TOCID.Value = DO.TOCID;
            _Label.Value = DO.Label;
            _FieldType.Value = DO.FieldType;
            _FieldNAme.Value = DO.FieldNAme;
            
            SqlParameter[] _params = new SqlParameter[] {
                _TOCID,
                _Label,
                _FieldType,
                _FieldNAme
            };

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

            return DataCommon.ExecuteScalar("[dbo].[PermitTableFieldReference_Update]", _params, pid);
        }
        /// <summary>
        /// Gets all PermitTableFieldReference records
        /// </summary>
        public static async Task<PermitTableFieldReferenceDO[]> GetAllAsync()
        {

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

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

                PermitTableFieldReferenceDO obj = new PermitTableFieldReferenceDO();
                
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                obj.Label = sr.GetString(sr.GetOrdinal("Label"));
                obj.FieldType = sr.GetString(sr.GetOrdinal("FieldType"));
                obj.FieldNAme = sr.GetString(sr.GetOrdinal("FieldNAme"));
                


                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Selects PermitTableFieldReference records by PK
        /// </summary>
        public static async Task<PermitTableFieldReferenceDO[]> GetByPKAsync(Int32 TOCID,
 String Label)
        {

            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            SqlParameter _Label = new SqlParameter("Label", SqlDbType.VarChar);
			
            _TOCID.Value = TOCID;
            _Label.Value = Label;
			
            SqlParameter[] _params = new SqlParameter[] {
                _TOCID,
                _Label
            };

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

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


            List<PermitTableFieldReferenceDO> objs = new List<PermitTableFieldReferenceDO>();
			
            while(sr.Read())
            {
                PermitTableFieldReferenceDO obj = new PermitTableFieldReferenceDO();
				
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                obj.Label = sr.GetString(sr.GetOrdinal("Label"));
                obj.FieldType = sr.GetString(sr.GetOrdinal("FieldType"));
                obj.FieldNAme = sr.GetString(sr.GetOrdinal("FieldNAme"));
                

                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Deletes a PermitTableFieldReference record
        /// </summary>
        public static async Task<int> DeleteAsync(PermitTableFieldReferenceDO DO)
        {
            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            SqlParameter _Label = new SqlParameter("Label", SqlDbType.VarChar);
            
            _TOCID.Value = DO.TOCID;
            _Label.Value = DO.Label;
            
            SqlParameter[] _params = new SqlParameter[] {
                _TOCID,
                _Label
            };

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

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