Merging DocumentQueries

Brenden Kehren asked on November 2, 2015 03:58

Here's my scenario, I have a page which displays a list of people. The people can be filtered by a location and/or a specialty. I've attempted creating a document query based on the selected value(s) (guid of the related page types) in the dropdowns. Problem is when I use something like below, it only uses the last InRelationshipWith property. Essentially I want to say 'get all the people who are related to the selected location and specialty.' If no locations are selected, just get all the people by the selected specialty and visa versa.

    var physicians = DocumentHelper.GetDocuments("custom.people")
                                .OnCurrentSite()
                                .Path(PeopleUrl, PathTypeEnum.Children)
                                .InRelationWith(ValidationHelper.GetGuid(specialty, Guid.Empty), "isrelatedto", RelationshipSideEnum.Right)
                                .InRelationWith(ValidationHelper.GetGuid(location, Guid.Empty), "isrelatedto", RelationshipSideEnum.Right)
                                .OrderBy(new string[] { "LastName", "FirstName" })
                                .Columns(new string[] { "DocumentName", "NodeAliasPath", "NodeLevel", "NodeOrder", "NodeGuid", "Photo", "FirstName", "LastName", "BioTeaser", "Degree", "PhoneNumber" })
                                .Published()
                                .FilterDuplicates();

I've also tried returning a dataset and using the Merge() method but it's not finding the duplicates and removing them even though the data is the same.

Any other suggestions?

Recent Answers


Pull Agency answered on November 3, 2015 18:59

Try removing the NodeGuid perhaps that's stopping the duplicate's to become unique values? Just a gut feel.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on November 13, 2015 19:01

The NodeGUID would be the guid of the left document which is the person. So it should really be the determining factor between 'Jim Smith' with GUID1 and 'Jim Smith' with GUID2.

1 votesVote for this answer Mark as a Correct answer

Timothy Fenton answered on November 23, 2015 14:10

hey brenden does adding an .And() between them help?

  var physicians = DocumentHelper.GetDocuments("custom.people")
                                .OnCurrentSite()
                                .Path(PeopleUrl, PathTypeEnum.Children)
                                .InRelationWith(ValidationHelper.GetGuid(specialty, Guid.Empty), "isrelatedto", RelationshipSideEnum.Right)
                                .And()
                                .InRelationWith(ValidationHelper.GetGuid(location, Guid.Empty), "isrelatedto", RelationshipSideEnum.Right)
                                .OrderBy(new string[] { "LastName", "FirstName" })
                                .Columns(new string[] { "DocumentName", "NodeAliasPath", "NodeLevel", "NodeOrder", "NodeGuid", "Photo", "FirstName", "LastName", "BioTeaser", "Degree", "PhoneNumber" })
                                .Published()
                                .FilterDuplicates();

if not I can test this a bit more with the devs!

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 1, 2015 16:03

I tried that as well Tim and no luck.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.