none
in a query with many to many relationships are inclueded a lot of objects RRS feed

  • Question

  • I have a many to many relation between two tables in my database, so in my edmx model I have only two tables, no the intermediate table. This tables are Movies and Genres.

    When I search for some movies, I get also the related entities, so with eager loading I populate the collection Genres of my entities Movies. Is what I want.

    The problem is that when in the result has more than one movie, the collection Genres of the entities Movies are populated, but the collection Movies of the entities Genres are populated too. So when I send to the repository one movie to be updated, if I attach the the entity to the context, I attach this movie and all the movies that have the same genres that the movie that I want to update. This is because in the genres of the entities are included the movies that are of the same genres than the movie that I want to update.

    So if in my first search I get a lot of movies, when I want to update one movie I send a lot of entities that I don't need to seed, so it is a lot of traffic in the network.

    is there any way when I search for results the collection of movies in the genres entities are not populated? Because I only populate the related entities of my main entity, movies, not all the collections of all the secondary entities.

    Thanks.

    Tuesday, June 18, 2013 5:40 PM

Answers