C# 使用 linq 查找字符串的最大值

2 c# linq string max

这就是我所拥有的,它一直返回 null。

当我添加 where 语句时,它无法识别 Convert.toInt32

var maxTopID = (from max in dbcontext.Topics.Local
               select max.TopicID).Max();
Run Code Online (Sandbox Code Playgroud)

Edp*_*per 5

如何转换TopicIDinSELECT并使用它String.IsNullOrEmpty()来删除空字符串,例如:

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

请参阅Demo