Select Maximum number from a numeric field in an entity (Dynamics CRM 2016)

Viewed 1019

What is the best way to retrieve the maximum value from a numeric field in an entity? Something like this in SQL Server: Select MAX(NumbericFieldName) From TableName.

I tried this:

var documentno = XrmContext.CreateQuery("nychro_traportaldocumentupload").Max(c => c.GetAttributeValue<Int32?>("nychro_portaldocumentreviewid"));

But I get the error "MAX is not supported"

What is the best way to resolve this?

2 Answers
Related