Posts

Latest post

Entity Framework Core Custom Pluralizer - .Net Core

This will automatically pluralize EF entities in .Net Core. The following Nuget packages need to be installed in your project. Microsoft.EntityFrameworkCore.Design Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.Tools PluralizeService.Core 1. Create a new folder called "Pluralization" 2. Create the following classes below:

Update audit fields automatically using Entity Framework

I use this snippet to make sure I am always setting the audit fields globally so you can implement in one place and you are done with the auditing part. There's no need to set audit fields in every class. Pre-requisites: The following database table columns must be present in at least 1 database table: CreatedByUserID (int) CreatedDate (datetime) LastUpdatedByUserID (int) LastUpdatedDate (datetime) A DbContext has been generated for your database

Read text file

This reads the text file and returns null if file does not exist.

Convert delimited string to string list

Use this if you want to convert a delimited string (e.g. comma delimited - "a,b,c,d") into List<string>.

Generate random base64 string using RandomNumberGenerator

Use this code to generate a random base64 string. This code can be used for generating random key or token strings.

Iterate between date range

Use this code to iterate each day inside a For Each loop