samedi 30 janvier 2016

Linq query returns the same names even though they should be different

I am new to EF6 and I have set up the Chinook database and gotten it working with SqlLite .NET provider on .NET Framework 4.0.

When I execute the following query, it executes without problems but the track names are all the same. They should be different because they have different track IDs and I have looked up those track IDs and they have different names.

var result = context.Playlists.Include(p => p.Tracks)
                .Where(p => p.Name == "Brazilian Music")
                .SelectMany(p => p.Tracks);

foreach(var p in result)
{
  Console.WriteLine(p.Playlist.Name + ", " + p.TrackId + ", " + p.Track.Name);
}

Appreciate any help.

Here is the output of my result:

Console Output

Aucun commentaire:

Enregistrer un commentaire