Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8832

Querying inherited page types when using generated page type class

$
0
0
I am attempting to use TreeProvider to query pages which all inherit from a base page type, here referred to as My.Product. I have also integrated the generated C# class for that base page type in order to get strongly-typed access to page type values.The following query, without using the generated page type, works fine: //returns all products as TreeNode var products = tree.SelectNodes() .OnSite("MyWebSite") .Types("My.Product*") Using the generated type with the generic version of SelectNodes, the Types extension can't be used, and no pages are returned. I assume because the inherited page types are not included. //returns nothing var products = tree.SelectNodes@Product@() .OnSite("MyWebSite"); Based on this answer I tried a cast: var products = tree.SelectNodes() .OnSite("MyWebSite") .Types("My.Product*") .ToList() .Cast@Product@(); But the cast failed: Unable to cast object of type 'CMS.Ecommerce.SKUTreeNode' to type 'CMS.DocumentEngine.Types.Product'.I've also tried constructing the page type object from the results of the query: var products = tree.SelectNodes() .OnSite("MyWebSite") .Types("My.Product*") .ToList() .Select(x =@ TreeNode.New@Product@(null, x, tree)) .ToList(); But the API doesn't like the class name mismatch: Input class name 'My.ProductInheritingType is not consistent with the requested type 'CMS.DocumentEngine.Types.Product' which has class name 'My.Product'. To fix this, use correct class name or null as the input parameter.Is there a way to use TreeProvider with my strongly typed page type, and retrieve pages which use inheriting page types?

Viewing all articles
Browse latest Browse all 8832

Trending Articles