This project is read-only.

Linq query confusion

Jun 26, 2012 at 2:28 PM

I am trying to extend the Store Controller "Browse" to include artist name when filtering according to its genre. The queries I have tried all break in different places 

MusicStoreEntitities extends dbContext & is defined as follows

public DbSet<Album> Albums { get; set; }       

public DbSet<Genre> Genres { get; set; }         

public DbSet<Artist> Artists { get; set; }   


first I tried extending the existing Store Controller Browse to include "Artist" or "Artists"

 storeDB.Genres.Include("Albums").Include("Artists").Single(g => g.Name == genre)

It  failed with  

 A specified Include path is not valid. The EntityType 'MVCMusic3.Models.Genre' does not declare a navigation property with the name 'Artists'.


Then I tried to apply a genre filter to the store manager version of the syntax

  var albums = db.Albums.Include(a => a.Genre).Include(a => a.Artist).Where(Inhere a miracle happens);

But I could not get a handle on a way to filter the query by the related child table ( IE from Album >>>> genreName via Genre Id).  


Any help would be greatly appreciated