khaliq
khaliq

Reputation: 108

How to search in umbraco 8.1 using custom property in where clause

var a = Nodes.Children.Where("CustomProperty == @0", "Value").First();

Throwing error {"No property or field 'CustomProperty' exists in type 'IPublishedContent'"}

Upvotes: 0

Views: 326

Answers (1)

Robert Foster
Robert Foster

Reputation: 2316

You need to use strongly typed models - e.g.:

var a = Nodes.Children<PageType>.Where(p => p.CustomProperty == "Value").First();

There are no dynamics in Umbraco 8 anymore, and the APIs have been simplified. Take a look at Shannon Deminick's "cheat sheet" from the uDuf conference earlier this year:

https://shazwazza.com/media/1032/uduf-2019.pdf

Upvotes: 3

Related Questions