© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
20 replies
kingofarrows

❔ .NET 6.0 - Nullable Strings with Dapper Model Classes

Hey everyone. I have a .NET 6.0 project that uses Dapper to communicate to a database and I have a class which contains properties that map to a table. One of my properties is a string and I'm getting the nullable warning (which goes away when I add the nullable?), however in the table the column is a non nullable string. What would be the recommended approach for this property? I could easily add the nullable? but then it means we can pass null in and out where that is not the case. On the opposite side, I could add a blank string assignment ('public string MyProperty { get; set; } = string.Empty;' ), however this is meant to be a dumb, model class and adding an assignment feels incorrect.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Nullable strings in .net 6
C#CC# / help
4y ago
❔ Reusing strings across classes
C#CC# / help
4y ago
✅ asp.net 6.0 + EntityFramework + IIS
C#CC# / help
3y ago
❔ Hardlink in Linux .NET 6.0
C#CC# / help
3y ago