var unos = new List<string> { "W", "w" };
var pesme = _entities.Tracks.Where(x => unos.Contains(x.Name) || unos.Contains(x.Genre.Name) || unos.Contains(x.Album.Title) || unos.Contains(x.Album.Artist.Name)).ToList();
foreach (var p in pesme) {
Console.WriteLine($"{p.Name}-{p.Album.Title}-{p.Album.Artist.Name}-{p.Genre.Name}");
}
CodePudding user response:
Actually you need to check Name
contains W
or w
. But now you are checking W
contains x.Name
!!
Try this one:
var unos = new List<string> { "W", "w" };
var pesme = _entities.Tracks.ToList().Where(x => unos.Any(t=> x.Name.Contains(t) || x.Genre.Name.Contains(t) /* rest of conditions*/ )).ToList();
foreach (var p in pesme) {
Console.WriteLine($"{p.Name}-{p.Album.Title}-{p.Album.Artist.Name}-{p.Genre.Name}");
}