I'm obtaining a list of 5 components from the broker using a simple Query:
Query myQuery = new Query();
Criteria myCriteria = null;
PublicationCriteria pubRelCriteria = new PublicationCriteria(iPublicationID);
ItemSchemaCriteria schemaRelCriteria = new ItemSchemaCriteria(id_schema);
ItemTemplateCriteria templateCriteria = new ItemTemplateCriteria(id_template);
// glue the metadata together
AndCriteria aCriteria = new AndCriteria(schemaRelCriteria, pubRelCriteria);
aCriteria = new AndCriteria(aCriteria, templateCriteria);
myCriteria = aCriteria;
myQuery.Criteria = myCriteria;
//Sort it
CustomMetaKeyColumn customMetaKeyColumnDate = new CustomMetaKeyColumn("Date", MetadataType.DATE);
myQuery.AddSorting(new SortParameter(customMetaKeyColumnDate, SortParameter.Descending));
// Display
String[] itemURI = myQuery.ExecuteQuery();
The problem is that the metadatafield "Date" that I need to use as the sort criteria is not mandatory, then if some component is published with this metadatafield empty, this component is not returned in the query.
Is there some way to return all the components despite the field of the sort criteria is empty?
Thanks!