diff --git a/dotnet/BeakPeekApi/Controllers/BirdController.cs b/dotnet/BeakPeekApi/Controllers/BirdController.cs index 50a53ae3..9d3855b4 100644 --- a/dotnet/BeakPeekApi/Controllers/BirdController.cs +++ b/dotnet/BeakPeekApi/Controllers/BirdController.cs @@ -294,7 +294,7 @@ public async Task>> GetBirdsByRef(int id) var birds = await _context.Provinces .Include(p => p.Bird) .Include(p => p.Pentad) - .Where(p => p.Bird!.Ref == id) + .Where(p => p.Bird != null && p.Bird.Ref == id) .ToListAsync(); if (birds == null || birds.Count == 0)