I have the following simple Linq query:
(from container in Container
join containerType in ContainerType on container.ContainerType equals containerType
where containerType.ContainerTypeID == 2
select container).Max (row => row.SerialNumber)
As is, this query works fine. The problem is that SerialNumber, in the DB, is an nvarchar type. When ContainerTypeID = 2, the values in this column will always be integers, but not zero-filled. Therefore, doing a Max, without casting all the serial numbers to integers, won't work (e.g., Max would select '2' over '10'). So, my question is, how can I cast all the values of row.SerialNumber to an integer so Max can find the greatest serial number?