You can also use Examine for that. Just create searchCriteria and set the search query like this:
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
searchCriteria.Field("yourContentPickerProperty", contentId);
var searchResults = searcher.Search(searchCriteria);
Query one to many
I have document type with content picker and I want to know how to find all content that is referencing particular content.
For example Content1 and Content2 is referencing Content 3. How can I get Content1 and Content 2 if I know id of Content 3.
You could install my nexu package : https://our.umbraco.org/projects/backoffice-extensions/nexu/
This stores all references as Umbraco relations.
You could use the relations api to get the data you want : https://our.umbraco.org/documentation/Reference/Management/Services/RelationService
Dave
Thank you Dave I will try it
You can also use Examine for that. Just create
searchCriteria
and set the search query like this:var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"]; var searchCriteria = searcher.CreateSearchCriteria(); searchCriteria.Field("yourContentPickerProperty", contentId); var searchResults = searcher.Search(searchCriteria);
I have new problem contentId is int but in database yourContentPickerProperty is stored as umb://document/0dec2b61774547b1b96956895d59f231
I have finished with something like this
is working on a reply...