My program keeps throwing an InvalidOperationException with the error “The null value cannot be assigned to a member with type System.Boolean which is a non-nullable value type”. I can’t make any sense of this because my code isn’t trying to assign anything, simply iterate through a list and generate string of all claim numbers (or return an empty string if the enquiry has no associated claims):
public string ClaimNumbers
{
get
{
if (Enquiry.Claims != null && Enquiry.Claims.Count>0)
{
var sb = new StringBuilder();
foreach (var claim in Enquiry.Claims)
{
sb.Append(claim.ClaimId.ToString("00000") + ", ");
}
return sb.ToString().Substring(0, sb.Length - 2);
}
return string.Empty;
}
}
The odd thing is that when I step through the code in the debugger and try to expand Enquiry.Claims.Count, I see:

But then when I pause a bit and step onto the next line it changes to:

I am using Linq to Sql, and Claims is an entity set, so I wondered if perhaps it was something to do with pulling the data from the database, however I’m not sure, so can’t think what the best way to tackle fixing it is.
I assume that the CLAIMS table has a column that is mapped to a boolean property in your
Claimsentity and that column contains at least one NULL value.