public class GameDBObject
{
public string? Id { get; set; } = null;
// other fields...
public IList<GameHistoryEntryView>? History { get; set; } = null;
}
public class GameHistoryEntry
{
// other fields...
public ICollection<GuessResult?>? Results { get; set; }
}
public class GuessResult
{
// a number of scalar fields
}
This works until I try to store a null entry in the GameHistoryEntry.Results list. As soon as I try to save the database context with a null entry in that list, I get a System.ArgumentNullException: 'Value cannot be null. (Parameter 'key')' error.
The collection already says the type is the nullable GuessResult type, so null should be allowed. How can I make this work?
So what I actually want to do is make it so individual items in the GameHistoryEntry.Results array can be null. Would setting e.Results itself to not be required do that, or would that just make it so the Results field itself could be null?