Posts Tagged: Util-a-day

Convert DataTable to Dictionary

/// <summary> /// Converts a DataTable to a dictionary. (NON PERFORMANT) /// </summary> /// <remarks> /// This method is usually used when running dynamic sql in databases that don’t support /// stored procs. The columns returned are unknown so we…Continue Reading →

c# Coalesce function

When you’ve been working heavily with c# for a few days, coalesce jumps into your head for a lot of c# issues. Heres a little helper to provide coalesce in .net /// <summary> /// Returns the first non null value,…Continue Reading →

UAD6 – Physical path to virtual

Simple util to take a physical path and gets its virtual equivalent. public static string PhysicalPathToVirtual(string path) { if (HttpContext.Current != null && !String.IsNullOrEmpty(path)) { return "/" + path.Replace(HttpContext.Current.Server.MapPath("/"), "").Replace(@"\", "/"); } else return null; } public static string PhysicalPathToVirtual(HttpContext…Continue Reading →