I am using .net 6 with Nullable Reference Type enabled, and when I use an anonymous type to get the results of a LINQ query I get a Warning Client is not null here. CS8619:Nullability of reference type in value of type <anonymous type: int ContractId, string Name, string Street> doesn't match type <anonymous type: int ContractId, string Name, string? Street>
Here is my code:
var contracts = _dbContext.Contracts.Select(
c => new
{
c.ContractId,
c.Client.Name,
c.Client.Street
}
).Where(c => c.ContractId == contractId).Take(9).ToList();
What is the proper way to make the query and avoid the warning?