标签:指定 async code epo ati == nbsp repo int
1.实现代码
/// <summary> /// 获取指定课程编号的总时长 /// </summary> /// <param name="courseId">课程编号</param> /// <returns></returns> public async Task<decimal> GetTotalDurationByCourseId(int courseId) { decimal totalDuration = 0; var result = _sectionInfoRepository.GetAll().AsNoTracking().Where(x => x.CourseId == courseId) .GroupBy(x => new { x.CourseId }) .Select(g => new { TotalDuration = g.Sum(x => x.ResourceDuration) }).FirstOrDefault(); var r = result.GetType().GetProperty("TotalDuration"); if (r != null) { totalDuration = Convert.ToDecimal(r.GetValue(result, null)); } return await Task.FromResult(totalDuration); }
标签:指定 async code epo ati == nbsp repo int
原文地址:https://www.cnblogs.com/LifeDecidesHappiness/p/9690135.html