Esempio n. 1
0
        /// <summary>
        /// 根据ID获取任务
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <TaskOptions> GetTaskById(int id)
        {
            string sql = @"SELECT * FROM TaskOptions WHERE Id = @id";

            using var con = new DapperDbContexts().Connection;
            TaskOptions task = await con.QueryFirstOrDefaultAsync <TaskOptions>(sql, new
            {
                id = id
            });

            return(task);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据名称获取任务
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="taskName"></param>
        /// <returns></returns>
        public async Task <TaskOptions> GetTaskByName(string groupName, string taskName)
        {
            string sql = @"SELECT * FROM TaskOptions WHERE TaskName = @taskName AND GroupName = @groupName";

            using var con = new DapperDbContexts().Connection;
            TaskOptions task = await con.QueryFirstOrDefaultAsync <TaskOptions>(sql, new
            {
                taskName  = taskName,
                groupName = groupName
            });

            return(task);
        }