views:

130

answers:

1

I have this query

this.FixturePartidoPuntaje.Load();     

var partidos = from q in this.FixturePartidoPuntaje
               where ( q.FixturePartido.Equipo.EquipoId.Equals(equipoId) ||
                      q.FixturePartido.Equipo1.EquipoId.Equals(equipoId)) &&
                      q.puntaje > 0
               select q;

The most important here is that this is a Jugador Entity.

How do I load the FixturePartido and ius children?

Thanks

+1  A: 

Use the .Include() command:

var partidos = from q in this.FixturePartidoPuntaje.Include("children")
               where (q.FixturePartido.Equipo.EquipoId.Equals(equipoId) ||
                      q.FixturePartido.Equipo1.EquipoId.Equals(equipoId)) &&
                      q.puntaje > 0
               select q;

"children" here is the name of the Navigational Property that you want to include, if my memory isn't way off...

Tomas Lycken
I get this error When I add the Include (Compile Time)'System.Data.Objects.DataClasses.RelatedEnd.Include(bool, bool, System.Collections.Generic.HashSet<System.Data.Objects.DataClasses.EntityReference>)' is inaccessible due to its protection level
Jedi Master Spooky
what does "this" hold?
Tomas Lycken
An additional question - did you use the singular or EntitySet name in the .Include() statement? It should be .Include("children") as opposed to .Include("child")...
Tomas Lycken
In EF 4 there is a PluralizationService that does it automatically.
Shimmy