this post was submitted on 24 Sep 2024
5 points (100.0% liked)

C Sharp

1537 readers
1 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 2 years ago
MODERATORS
 

This may be common knowledge but I've never seen it online.

[MaybeNull] public Entity Entity { get; set; }

You now get a warning when accessing without a check and when setting to null.

Sadly you still need to ! in quries

you are viewing a single comment's thread
view the rest of the comments
[–] GetOffMyLan 2 points 1 month ago

Exactly.

What we need is someone to create an analyzer that recognises when you are writing an ef query or if you've included and disabled the warnings.

The actual issue is using the same model for the database and query results. I.e. it's not nullable in the database but could be after a query. But there's no nice way to implement this without mapping everything to a dto.