Try changing your query to this:
db.Leads.Where(l => l.Date.Day == date.Day
&& l.Date.Month == date.Month
&& l.Date.Year == date.Year
&& l.Property.Type == ProtectedPropertyType.Password
&& l.Property.PropertyId == PropertyId)
.Select(l => l.Amount)
.DefaultIfEmpty(0)
.Sum();
This way, your query will only select the Amount
field. If the collection is empty, it will return one element with the value of 0
and then the sum will be applied.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…