public int SongCounts(SearchOptions option) { using (var db = new SongContext(_connectionStrings)) { var count = 0; switch (option) { case SearchOptions.All: count = db.Songs.Count(s => s.Status != Status.Delete); break; case SearchOptions.Complete: count = db.Songs.Count(s => s.Status == Status.Active); break; case SearchOptions.Incomplete: count = db.Songs.Count(s => s.Status == Status.Incomplete); break; case SearchOptions.New: count = db.Songs.Count(s => s.Status == Status.New); break; } db.Dispose(); return(count); } }
public Song GetSong(int songid) { using (var db = new SongContext(_connectionStrings)) { var so = db.Songs.SingleOrDefault(s => s.Id == songid && s.Status != Status.Delete); db.Dispose(); return(so); } }
public List <Song> GetTop20PlayedSongs() { using (var db = new SongContext(_connectionStrings)) { var results = (from so in db.Songs orderby so.PlayedCount descending select so).Take(20); var returnedList = results.ToList(); db.Dispose(); return(returnedList); } }