Getting a List of PageNodes with Specific Controls
I was having an issue writing some lambda code to get a list of pages with a specific control object type.
Say I am looking for the "widget" type
MyProject.NameSpace.ControlType
How would I write the lambda?
var pm = PageManager.GetManager();var pnWithObjectType = pm.GetPageNodes() .Where(pn => pn.Page != null) // unsure how to add this piece below // this does not compile .Where(pc => pc.Page.Controls.Where(control => control.ObjectType == "MyProject.NameSpace.ControlType"));Hi James,
Try this:
var pm = PageManager.GetManager(); var pnWithObjectType = pm.GetPageNodes() .Where(pn => pn.Page != null) .Where(pd => pd.Page.Controls.Any(c => c.ObjectType.StartsWith(typeof(MyProject.Namespace.ControlType).FullName)));This is exactly what I needed! Throwing it on our utility class. Thanks so much for your help.