Get Slug of string using c#

public static string ToSlug(string value) { //First to lower case value = value.ToLowerInvariant(); //Remove all accents var bytes = Encoding.GetEncoding(“Cyrillic”).GetBytes(value); value = Encoding.ASCII.GetString(bytes); //Replace spaces value = Regex.Replace(value, @”\s”, “-“, RegexOptions.Compiled); //Remove invalid chars value = Regex.Replace(value, @”[^\w\s\p{Pd}]”, “”, RegexOptions.Compiled); //Trim dashes from end value = value.Trim(‘-‘, ‘_’); //Replace double occurences of – or \_ […]

Continue reading


Difference between Configuration.cs vs Database Initializer in Entity Framework

Difference between Configuration.cs vs Database Initializer in Entity Framework Configuration.cs file located inside Migrations folder, which will be created when we execute the command “Enable-Migrations” in Package Manager Console. We can make use of this class for seeding the datas into database. This class will seed the database whenever we execute the Update-Database command in […]

Continue reading