3

I am trying to get the List of Components using the Schema ID. I am doing following steps.

var queryParameters = new ExtendedQueryParameters();
queryParameters.PublicationId = publicationID;
queryParameters.QuerySchemas = new[] { schemaID.ToString() };
ComponentFactory.FindComponents(queryparameters);

Here, SchemaID is the short ID of Schema.

  1. Do I need to put whole TCMURI or am I correct in this?
  2. How to sort list by Last Published Date?
  • 1
    I got the answer for my 1st question. We need to put whole TCM URI of the Schema. Please help for the second question. How can I sort it by last published date? – Sharad Kumar Sangal Apr 25 '14 at 11:01
5

You are using the DD4T stack. Which is fine, although I would recommend to use the standard CD API, as Mihai mentions.

To sort the list by Last Publish Date you should be able to do this (Untested):

var queryParameters = new ExtendedQueryParameters();
queryParameters.PublicationId = publicationID;
queryParameters.QuerySchemas = new[] { schemaID.ToString() };
queryParameters.QuerySortField = "ItemLastPublishedDate";
queryParameters.SortType = ExtendedQueryParameters.MetaSortFieldType.DATETIME;
queryParameters.QuerySortOrder = ExtendedQueryParameters.MetaQueryOrder.Descending
ComponentFactory.FindComponents(queryparameters);
4

I think you are quoting some custom code. What is ExtendedQueryParameters and ComponentFactory? They are not Tridion CD API.

For a standard CD API query, you would use the Tridion.ContentDelivery.DynamicContent.Query namespace. This allows you to specify Criterias and filter/modifiers such as number of results and sorting direction.

A pseudo-code example is the following:

Criteria criteria = new ItemSchemaCriteria(123);
Query query = new Query(criteria);
SortParameter sorting = new SortParameter(SortParameter.ItemLastPublishColumn, SortParameter.Ascending);
query.AddSorting(sorting);
string[] ids = query.ExecuteQuery();
  • ExtendedQueryParameters is DD4T. :) – Raimond Apr 25 '14 at 12:03
  • It did seem familiar :) – Mihai Cădariu Apr 26 '14 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.