This topic explains how to query instances of documents. The examples below show you how to query all of the available documents or how to query only a specific document by its ID.
NOTE: The code examples below work with the ID of the master version of the document and return the live version of the document. For more information about other scenarios, see For developers: Query master and live versions.
When querying the live version of a specific document by the ID of its master version, you must perform the following:
NOTE: The live version is used only when displaying the document in a front-end scenario. If you want to manipulate the document, consider using the master version. To transfer the changes to the live version, publish the master version.
The following code sample queries a document by its title:
The following code samples query the live version of a document by the ID of its master version. To get the ID of the document, use the following code samples:
First, you get an instance of the LibrariesManager class. You get the specified document by querying all documents and filtering the collection by the Id property of the document. If the document exists, you get its live version. If no live version exists (i.e. the item has not been published), you return null. Finally, you return the live version.
You can also use the following code to retrieve the document:
NOTE: When the document does not exist, an exception of type ItemNotFoundException is thrown.
First, you get the singular document facade of the master version with the specified ID. Then, to load the live version of the document, you call the GetLive method of the facade. Finally, to get the instance of the live version, you call the Get method.
To query documents by a document library, you must perform the following:
NOTE: Another way of getting the documents from a specific library, is to query all the documents and filter the collection by the ID of the document library. You can find an example of this approach in the next section.
Use the following code samples:
When querying all documents, you must perform the following:
NOTE: You can filter the query to get a specific set of documents. For example, you can get the documents from a specific library.
The following code queries all published documents.
In this code example you additionally filter the collection by the ID of the parent document library.
NOTE: You can filter the query to get a specific set of documents. For example, you can get the documents from a specific library:
In this code example you use the plural facade for the documents and filter them by the ID of the specified document library. Then, you get the live versions of the selected documents.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity