LINQ,检查这个字符是否包含在我的数据库中的一些表中

LINQ, to check if this characters contains in my some tables in my DB

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}");
            }

实际上您需要检查 Name 是否包含 Ww。但是现在您正在检查 W 包含 x.Name!!

试试这个:

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}");
                }