NOTE: This has been answered as duplicate in the comment below.
I am having trouble getting RIA Services to return the data I need and not more than the data I need. I have a parent object (Project) which contains a number of children. One is a Component (one Component per Proj开发者_运维问答ect). Another is a ProjectParticipant which needs to be limited based on the ParticipantRole, and I also need to grab the Person information (related to ProjectParticipant).
Here is some code I had earlier tried:
public IQueryable<IMSModel.Project> GetProjectHierarchy(String id)
{
return this.ObjectContext.Projects
.Include("Component")
.Include("ProjectParticipants")
.Include("ProjectParticipants.Person")
.Where(p => p.Program.ProgramType.lookupName == "EVDBE" &&
p.ProjectOrgs.Any(po => po.orgId == id) &&
p.ProjectParticipants.Any(pp => (pp.postId == id)) &&
p.ProjectParticipants.Any(pp => pp.PersonStatus.lookupName == "A") &&
p.ProjectParticipants.Any(pp => pp.ParticipantRole.participantInd == "Y"))
.OrderBy(p => new { p.fiscalYear, p.title })
.OrderByDescending(p => p.fiscalYear);
}
This doesn't work too badly, but I end up getting ProjectParticipant objects that I do not want. What I really want to do is limit the ProjectParticipant objects to those that have ParticipantRole.participantInd == "Y".
I tried another possible syntax for this, which is as follows:
public IQueryable<IMSModel.Project> GetProjectHierarchy(String id)
{
return this.ObjectContext.Projects
.Include("Component")
.Join(this.ObjectContext.ProjectParticipants
.Include("ProjectParticipants.Person")
.Where(
pp => pp.ParticipantRole.participantInd == "Y" &&
pp.postId == id &&
pp.PersonStatus.lookupName == "A"
)
, p => p.id
, pp => pp.projectId
, (p, pp) => p )
.Where(p => p.Program.ProgramType.lookupName == "EVDBE"
&& p.ProjectOrgs.Any(po => po.orgId == id));
}
I would think that this would return something a lot closer to what I might want. The only issue is that I don't get anything back in my hierarchical tree view. Something was returned, as blank locations were created for each record, but my bindings are not displaying any information. The bindings for the first example do show data, whereas the bindings for the second (more limited result set as I am not using Any()) does not show data.
I have been banging my head against this one for quite some time now and cannot resolve. Any assistance would be great.
精彩评论