0

I've just learned how to include multpiple level properties with Entity Framework ( on this thread : Entity Framework - Include Multiple Levels of Properties). But things fail when I'm attempting to include a collection containing the base entity.

Here is my base class :

public partial class Artiste
{
    public Artiste()
    {
        this.Parutions = new HashSet<Parution>();
    }

    public System.Guid Id { get; set; }
    public string Nom { get; set; }

    public virtual ICollection<Parution> Parutions { get; set; }
}

And my second class :

public partial class Parution
{
    public Parution()
    {
        this.Artistes = new HashSet<Artiste>();
    }

    public System.Guid Id { get; set; }
    public string Title { get; set; }

    public virtual ICollection<Artiste> Artistes { get; set; }
}

Artiste have many Parutions. Parution have many Artistes. When I'm querying an Artiste while including his Parutions :

dbQuery.Include(a => a.Parutions);

In the Parutions Artistes, I've got only the queried Artiste (one Artiste). I don't get the other Artistes. I've tried this :

dbQuery.Include(a => a.Parutions.Select(p => p.Artistes));

But it gives some error that Artiste is already loaded.

How to achieve this ?

Community
  • 1
  • 1
bob
  • 774
  • 1
  • 7
  • 16
  • possible duplicate of [Entity Framework Many to Many works but Include does not](http://stackoverflow.com/questions/15556134/entity-framework-many-to-many-works-but-include-does-not) – t3z Sep 03 '14 at 21:54
  • No it's not a duplicate since the Artiste.Parutions are filled. The problem is with the Artiste.Parutions.Artistes collection here. – bob Sep 04 '14 at 07:28

0 Answers0