We have multiple content databases and each content database have multiple site collection. Site collection is having document libraries. We are using them to store documents. We have guid (UniqueId) of content database, site collection, document library and uploaded document. Is there any way to quickly find the document using Server Object Model rather than using old approach (using objects SPSite, SPWeb, SPList, SPQuery) ? Can you please provide me any code or link through which I can resolve the above issue ?
Asked
Active
Viewed 1,083 times
1 Answers
0
I'm afraid you cannot query multiple sites with one single query using SharePoint server object model. What you can do instead is to use "SPSiteDataQuery" which queries ONE site collection and in multiple libraries. read about it here:
Another option which will not use Server Object Model is to query the SQL Server Database directly (which is not recommended: Five Reasons Not to Directly Query SharePoint Databases). In order to do that you have to query against "All Docs" table in the content database of your web applications, gather the results, and use SiteId, WebId, ListId and ItemId columns and then use Server Object Model to find your document.

Paiman Samadian
- 297
- 1
- 16