public async Task <AlarmMessageSubSearchModel> GetAlarmMessageByAlarmIdAsync(int alarmId) { var alarm = await _context.Alarms .Include(a => a.AlarmMessage).Where(a => a.AlarmId == alarmId).FirstOrDefaultAsync(); var alarmMessage = alarm == null ? null : alarm.AlarmMessage; var alarmMessageSearch = AlarmMessageOperator.SetAlarmMessageSubSearchModel(alarmMessage); return(alarmMessageSearch); }
public AlarmMessageSearchModel FindById(int alarmMessageId) { var result = _context.AlarmMessages .Where(v => v.AlarmMessageId == alarmMessageId); result = (IQueryable <AlarmMessage>)ExpandOperator.ExpandRelatedEntities <AlarmMessage>(result); var alarmMessage = result.FirstOrDefault(); var alarmMessageSearch = AlarmMessageOperator.SetAlarmMessageSearchModelCascade(alarmMessage); return(alarmMessageSearch); }
public IEnumerable <AlarmMessageSearchModel> GetAll() { var queryData = from A in _context.AlarmMessages select A; var result = QueryOperate <AlarmMessage> .Execute(queryData); result = (IQueryable <AlarmMessage>)ExpandOperator.ExpandRelatedEntities <AlarmMessage>(result); //以下执行完后才会去数据库中查询 var alarmMessages = result.ToList(); var alarmMessagesSearch = AlarmMessageOperator.SetAlarmMessageSearchModelCascade(alarmMessages); return(alarmMessagesSearch); }