When the collection is empty in Linq2SQL the aggregate returns null
. If the value being aggregated is non nullable this will throw an exception. To solve the problem, cast the value being aggregated to a nullable type.
from o in dbContext.Ammounts
where o.Value > ((from p in dbContext.Payments select p)
.Sum(p => (decimal?)p.Value)) ?? 0m);