I am trying to get all the components and their data using Tridion Core services. Here is the code.
SearchQueryData filter = new SearchQueryData();
filter.FullTextQuery = "Sample";
filter.ItemTypes = new ItemType[] { ItemType.Component };
filter.SearchIn = new LinkToIdentifiableObjectData() { IdRef = ARTICLE_FOLDER_URI };
BasedOnSchemaData articleSchema = new BasedOnSchemaData();
articleSchema.Schema = new LinkToSchemaData() { IdRef = ARTILCE_SCHEMA_URI };
articleSchema.Field = "Author";
articleSchema.FieldValue = "Ravi*";
filter.BasedOnSchemas = new BasedOnSchemaData[] { articleSchema };
var results = _client.GetSearchResults(filter); // Here I got results based on the filters, but it has only TCMIds
foreach (var comp in results)
{
var item = (ComponentData)comp; //Here item.Content is null.
}
This code gives me search results with TCM ids only. How do I get the component data also? (_client.Read(tcmId, new ReadOptions());
I can use this method to get the component data, but again I am hitting the database for individual items, which I don't want.