More in this section

Forums / Bugs & Issues / Issue with TaxonomyManager in Sitefinity 10

Issue with TaxonomyManager in Sitefinity 10

4 posts, 1 answered
  1. Chaitanya
    Chaitanya avatar
    22 posts
    Registered:
    14 Oct 2013
    23 Aug
    Link to this post

    Hello,

    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

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    23 Aug in reply to Chaitanya
    Link to this post
    What about .ToList before the OrderBy to force the query to memory instead of sql?
  3. Chaitanya
    Chaitanya avatar
    22 posts
    Registered:
    14 Oct 2013
    24 Aug in reply to Steve
    Link to this post
    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.
  4. Chaitanya
    Chaitanya avatar
    22 posts
    Registered:
    14 Oct 2013
    11 Sep
    Link to this post

    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();
    Answered
4 posts, 1 answered