When finding the maximum value of an all-digit character column or sorting the column numerically, the following syntax will throw an error in the title:
context.Table.Max(p => Convert.ToInt32(p.Id));
Before Entity Framework 4.0, we could write this without error:
context.Table.Select(p => p.Id).ToArray().Max(p => Convert.ToInt32(p))
After Entity Framework 4.0, we can directly execute SQL statements, which are written as follows:
context.ExecuteStoreQuery<Int32>("select max(convert(int,Id)) from Table").First();