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


How to search by Date Range in Entity Framework

Date Range in Entity Framework If we want to search entity with date range, assume we are passing StartDate, and EndDate as Request.Params, in MM/dd/yyyy format. public ActionResult Search() { var StartDate = Request.Params[“StartDate”]; var EndDate = Request.Params[“EndDate”]; var visits = visitBAL.GetVisits(); if (StartDate != null && !StartDate.Equals(“”)) { visits = visits.Where(v => v.DateStart >= […]

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