C# Finding the maximum value of a string with linq

c#, linq, max, string

Solution

How about converting the `TopicID` in `SELECT` and use `String.IsNullOrEmpty()` to remove empty string, like:

 var maxTopID = (from max in dbcontext.Topics.Local
                 where !String.IsNullOrEmpty(max.TopicID)
                 select Convert.ToInt32(max.TopicID)).Max();

See the Demo

Problem

This is what I have and it keeps returning null. It doesn't recognize the Convert.toInt32 when I add a where statement ``` var maxTopID = (from max in dbcontext.Topics.Local select max.TopicID).Max(); ```

Original source