You must use this: var genreModel = from p in storeDB.Genres. Include("Albums") where p. Name == genre select p; return View(genreModel.Single()) Include must be part of query.
Calling it in advance doesn't work. You can do this: var query = storeDB.Genres. Include("Albums"); var genreModel = from p in query where p.Name == genre select p Also you can't create projection to entity class ( new Genre ).
You must select it directly.
You must use this: var genreModel = from p in storeDB.Genres. Include("Albums") where p. Name == genre select p; return View(genreModel.Single()); Include must be part of query.
Calling it in advance doesn't work. You can do this: var query = storeDB.Genres. Include("Albums"); var genreModel = from p in query where p.Name == genre select p; Also you can't create projection to entity class (new Genre).
You must select it directly.
I think I tried this earlier. I will give this a shot and report back to you thanks for answering – davey Apr 5 at 21:51 Agreed. Projections aren't allowed in Linq to EF, if I recall correctly.
– neontapir Apr 5 at 22:09 3 @neon: Projection are allowed but you mustn't project to mapped entity. – Ladislav Mrnka Apr 5 at 22:10 Thanks, @Ladislav! – neontapir Apr 5 at 22:11.
Thanks Ladislav that worked perfectly. Why though when I try use projection which I may need to do to only get fields I need, I get this error: *The model item passed into the dictionary is of type 'f__AnonymousType04System. Int32,System.
String,System. String,System.Collections.Generic. List1MvcMusicStore.Models.
Album', but this dictionary requires a model item of type 'MvcMusicStore.Models. Genre'. * var genreModel = from p in storeDB.Genres.
Include("Albums") where p. Name == genre select new { p. GenreId, p.Name, p.
Description, p. Albums }; return View(genreModel.Single()).
I get this error. The entity or complex type 'StreamerHeadline' cannot be constructed in a LINQ to Entities query. What I supposed to do?
Create a custom class?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.