How to Search On multiple Profile properties
The following is a sample code on how to search for multiple profile properties. Note that the Profiles Search handles only And operator when joining search clauses.
// Declare return variable. string returnValue = String.Empty; // Declare ProfileManagementContext. ProfileManagementContext profile; // Instantiate ProfileManagementContext as an instance of the // Profiles Web service. profile = ProfileManagementContext.Create("https://localhost/ProfilesWebService/ProfilesWebService.asmx"); // Declare and instantiate SearchClause and SearchOptions objects. SearchClause searchClause = null; SearchClause rightClause = null; SearchOptions searchOptions = new SearchOptions(); // Build dataset of searchable entities for a profile. DataSet searchableEntities = profile.GetSearchableEntities(); // Build search clause for the UserObject. SearchClauseFactory factory = profile.GetSearchClauseFactory(searchableEntities, "Address"); searchClause = factory.CreateClause(ExplicitComparisonOperator.Equal, "address_line1", "One Microsoft Way"); rightClause = factory.CreateClause(ExplicitComparisonOperator.Equal, "address_line2", "One Microsoft Way"); searchClause = factory.IntersectClauses(searchClause, rightClause); // Set number of records to return. searchOptions.NumberOfRecordsToReturn = 10; // Specify profile properties to return in the search dataset. searchOptions.PropertiesToReturn = "address_id, address_line1, address_line2"; // Execute the search against the Profiles Web service. DataSet searchResults = profile.ExecuteSearch("Address", searchClause, searchOptions); |
Comments
Anonymous
March 15, 2007
The comment has been removedAnonymous
June 09, 2008
how to search multiple profiles with OR operator.Anonymous
June 11, 2008
The OR operator is not supported in Profile API. -Max