Home > Mobile >  C# Fields inside objects in a list being nulled out after LINQ WHERE
C# Fields inside objects in a list being nulled out after LINQ WHERE

Time:06-24

 IEnumerable<Game> games = await _context.Games
            .Include(e => e.Challenger)
            .Include(e => e.Opponent)
            .Include(e => e.Winner)
            .ToListAsync();

When i query a table using Entity Framework 6 in .Net Core App, i get a list with the correct elements from the database, all looks good so far:

first screenshot, not filtered

Then on the second screenshot you can see that it's filtered by finished value equals to "false" second screenshot, filtered by finished == false

Try running the query like

    games = games.Where(g => g.Finished == true); //or .Where(g => g.Finished)

And you will probably see different results. Hope this will help

  • Related