示例#1
0
        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);
            }
        }
示例#2
0
 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);
     }
 }
示例#3
0
 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);
     }
 }