/// <summary> /// 获取数据 /// </summary> /// <param name="query">查询条件</param> /// <returns></returns> protected override async Task <TriggerCondition> GetDataAsync(IQuery query) { List <TriggerMonthlyConditionEntity> monthlyEntityList = await repositoryWarehouse.GetListAsync(query); if (monthlyEntityList.IsNullOrEmpty()) { return(null); } string triggerId = monthlyEntityList.First().TriggerId; TriggerMonthlyCondition monthlyCondtion = new TriggerMonthlyCondition(triggerId) { Days = monthlyEntityList.Where(c => c.TriggerId == triggerId).Select(c => c.MapTo <MonthConditionDay>()).ToList() }; return(monthlyCondtion); }
/// <summary> /// 获取数据列表 /// </summary> /// <param name="query">查询条件</param> /// <returns></returns> protected override async Task <List <TriggerCondition> > GetDataListAsync(IQuery query) { List <TriggerMonthlyConditionEntity> monthlyEntityList = await repositoryWarehouse.GetListAsync(query); if (monthlyEntityList.IsNullOrEmpty()) { return(new List <TriggerCondition>(0)); } IEnumerable <string> triggerIds = monthlyEntityList.Select(c => c.TriggerId).Distinct(); List <TriggerCondition> monthlyConditions = new List <TriggerCondition>(); foreach (string triggerId in triggerIds) { TriggerMonthlyCondition monthlyCondtion = new TriggerMonthlyCondition(triggerId) { Days = monthlyEntityList.Where(c => c.TriggerId == triggerId).Select(c => c.MapTo <MonthConditionDay>()).ToList() }; monthlyConditions.Add(monthlyCondtion); } return(monthlyConditions); }