C#C
C#3y ago
1grumpydev

❔ How to handle null in Interface

I'm trying to learn .Net Core MVC and I'm following a course where the following code gives a warning of a possible null reference return. Can some one tell me how to best handle this?

public async Task<T> GetByIdAsync(int id) { var result = await _context.Set<T>().FirstOrDefaultAsync(n => n.Id == id); return result; }
Was this page helpful?