I am building a site on asp.net MVC and I am using the repository interface to use the repository in memory and use the database.
I have all my relationships fixed, I mean, for example, when I have one contact than it has addresses, so ... when I add one address to this contact, automatically fix the relashionship for the address. contact points to contact, and I leave the virtual properties for the entity infrastructure by creating a proxy and then using the database repository.
My question starts here:
I have one such request:
return query.Where(c => c.UserID == clientId) .Include(c => c.AssignedProjects) .Select(c => new UserDetailsData<Client> { User = c, IssuesCount = c.IssuesReported.Count() }).Single();
which uses include. If I delete Select assignProjects, there will be projects for this client, but when I turn on Select AssignedProjects, this is null and the anonymous object is fine, but .. the user does not contain any AssignedProjects.
In memory, I can do this, but with EF, I cannot.
The last graph I want is .. A user with a client ID, having a collection of AssignedProjects with his projects and creating an anonymous object with the user (along with the collection) and the release of DataCount to show AssignedProjects, user information and the number of problems reported customer.
Does anyone know how I can solve this?
source share