void GetStatus() { try { using (var db = new OeedbContext()) { StatusCollection.Clear(); StatusCollection.AddRange( db.Alarms .Include(m => m.StatusInfo) .Where(x => x.StatusInfo.StationId == StationIndex + 1) .Where(x => x.Time > FromDateTime && x.Time < ToDateTime) .OrderBy(x => x.Time)); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }