KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to get the SUM of "bookings" and I get error "The cast to value type 'Int32' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type." var bookings = entities.Bookings.Where(x => x.ID == id && x.StartDate <= bookingEnd && x.EndDate >= bookingStart) .Sum(x => x.BookingQuantity); How shall I fix this? I need to get 0 if it ever gets to be null else its bookings.
Tags (comma-separated)
Save Edits
Cancel