Issue with TaxonomyManager in Sitefinity 10

Posted by Community Admin on 04-Aug-2018 09:26

Issue with TaxonomyManager in Sitefinity 10

All Replies

Posted by Community Admin on 23-Aug-2017 00:00


We recently upgraded our Sitefinity version from 8 to 10. In a scenario we are fetching hierarchical taxonomies as below

var someTaxa= manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Taxonomy.Name == "some-name");
return manager.GetTaxa<HierarchicalTaxon>()
                .Where(t => (t.Parent != null && t.Parent.Name == "X" && t.Taxonomy.Name == "some-other-name")
                && (!someTaxa.Any(pw => pw.Name == t.Name))) //Filter out Taxanomies that have no "some-name".
                .OrderBy(t => t.Ordinal).ToList();


This was working fine in Sitefinity 8, after upgrade it threw an error of type "Telerik.OpenAccess.Exceptions.DataStoreException"  with message "Error executing query: Telerik.OpenAccess.RT.sql.SQLException: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified."

Is there any change in implementation of taxonomy manager and how to write query for the given scenario

Posted by Community Admin on 23-Aug-2017 00:00

What about .ToList before the OrderBy to force the query to memory instead of sql?

Posted by Community Admin on 24-Aug-2017 00:00

Tried that. "OrderBy(t => t.Ordinal)" is not causing any issues, it's "order by title" added by taxonomy manager for the first query(order by in sub query).  However if I use ToList() on first query as well as manager.GetTaxa<HierarchicalTaxon>().ToList() on second query, it works. But I do not want to fetch all the hierarchical taxonomy before filtration.

Posted by Community Admin on 11-Sep-2017 00:00

Simplified the query as below, so it wont have sub query.


var someTaxa= manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Taxonomy.Name == "some-name").ToList();
 var someOtherTaxa= manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Parent != null && t.Parent.Name == "X" && t.Taxonomy.Name == "some-other-name").ToList();
 return someOtherTaxa.Where(t => !someTaxa.Any(s => s.Name == t.Name)).OrderBy(t => t.Ordinal).ToList();

This thread is closed