static void findArtistsAlbum() { using (var db = new chinookContext()) { Console.WriteLine("Enter In Part Of The Name of the Artist: "); string name = Console.ReadLine(); Console.WriteLine("===List of Artists and Albums==="); var artistsAlbums = (from art in db.Artists join alb in db.Albums on art.ArtistId equals alb.ArtistId select new { art.Name, alb.Title }) .Where(i => i.Name.ToLower().Contains(name.ToLower())) .OrderBy(x => x.Name) .ThenBy(y => y.Title); // var aa = artistsAlbums; foreach (var list in artistsAlbums) { Console.WriteLine($"Name: {list.Name} - Album: {list.Title}"); } prompt(); } }
static void listArtists() { using (var db = new chinookContext()) { //List of Artists Console.WriteLine("===List of Artists==="); var artists = db.Artists.Select(x => x.Name).ToList(); foreach (string artist in artists) { Console.WriteLine($"Name: {artist}"); } } }
static void listArtistsAlbum() { using (var db = new chinookContext()) { //List of Artists Console.WriteLine("===List of Artists and Albums==="); //var artistsAlbums = db.Artists.Join(db.Albums, x => x.ArtistId, y => y.ArtistId, (x, y) => x).ToList(); var artistsAlbums = (from art in db.Artists join alb in db.Albums on art.ArtistId equals alb.ArtistId select new { art.Name, alb.Title }) .OrderBy(x => x.Name).ThenBy(y => y.Title); // var aa = artistsAlbums; foreach (var list in artistsAlbums) { Console.WriteLine($"Name: {list.Name} - Album: {list.Title}"); } prompt(); } }