Coding Standards
C#
Use the explicit type instead of var
Do not use _ for instance variable names
Use StronglyTypedId for Entity Identifiers
We use the NuGet package StronglyTypedId for entity IDs. Instead of creating an entity with an int, string, or Guid property for its Id, we first create a wrapper type. The author of the library has written a blog post series on why we should do this, so we won’t go into the details why.
Always use a CancellationToken with async methods
Using a CancellationToken is highly recommended for performance reasons, so we should always use them.
-
When creating an
asyncmethod, the last argument should be aCancellationTokennamedcancellationToken. -
When calling a method that accepts a
CancellationToken, always give it one.
SQL
Table names are always plural
Table names should always be the pluralized version of the noun, e.g. Employees and not Employee.
By convention, in SQL Server, table names are singular. We are bucking the convention and have decided that table names should be plural.
Keywords are always all-caps
Keywords in SQL statements should be in all caps so they are easier to see
All constraints should be named
Instead of relying on the database server to generate generic names for your contraints, always explicitly name them.