I have the following Linq query:
(from container in Container
join containerType in ContainerType on container.ContainerType equals containerType
where containerType.ContainerTypeID == someIDValue
select container).Max (row => Convert.ToInt64(row.SerialNumber))
This query works great as long as at least one Container row meets the criteria. If no rows meet the criteria, I get the following error:
The null value cannot be assigned to a member with type System.Int64 which is a non-nullable value type
Is there a way I can rewrite this so that if no rows satisfy the query an arbitrary value gets returned, say a -1?