Why does HierarchicalTaxonomy contain a IList<Taxon> c

Posted by Community Admin on 04-Aug-2018 04:15

Why does HierarchicalTaxonomy contain a IList collection

All Replies

Posted by Community Admin on 12-Feb-2013 00:00

...and not an IList<HierarchicalTaxon> collection?


Posted by Community Admin on 15-Feb-2013 00:00

Hi,

HierarchicalTaxonomy inherits from Taxonomy base class where the Taxa is ot type IList<Taxon>, HierarchicalTaxon have Subtaxa of type IList<HierarchicalTaxon>

Greetings,
Stanislav Velikov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 15-Feb-2013 00:00

That's what I mean...why do we have to do some casting, can't it be more elegant than that?

TaxonomyManager manager = TaxonomyManager.GetManager();
 
            var taxonomyParent = manager.GetTaxonomies<HierarchicalTaxonomy>().FirstOrDefault(x => x.Name == fieldName);
             
            var taxons = taxonomyParent.Taxa.Where(x => categories.Contains(x.Id)).Select(x => (HierarchicalTaxon)x);
 
            return taxons.ToList();

...or whatever

This thread is closed