Posts

Showing posts from September, 2019

Dictionary in C#

Dictionary is one of the mostly used generic collection in C#. It is a key and value pair collection.Each key inside this collection must be unique. It resides inside System.Collections.Generic library. Example using System; using System.Collections.Generic; public class Program { public static void Main() { CollectionExample(); } public static void CollectionExample() { //Creating new dictionary Dictionary<string,string> userDetails = new Dictionary<string,string>(); //Adding values to dictionary userDetails.Add("Saravanan","SoftwareDeveloper"); userDetails.Add("Aravind","SoftwareDeveloper"); userDetails.Add("Ajith","Programmer Analyst"); userDetails.Add("Prakash","lecturer"); //updating values of dictionary userDetails["Ajith"]="Dotnet Developer"; //Removing values userDetails.Remove("Prakas...

Routing in MVC

*Route is a URL Pattern.  It direct HTTP requests. *Routing is a part of MVC Architecture. *Process of mapping incoming requests to particular MVC controller actions. There are 2 namespaces available to work with proper routing. i) System.Web.Mvc ii) System.Web.Routing Default routes are mentioned in the RouteConfig class. Default routes contain 3 properties i)name- Route name. Route name can't be duplicated. ii)URL-Pattern of URL. Request URL should be  matched with the given URL patterns  otherwise error will be thrown. iii)defaults- Default controller and action name will be given here. Example using System.Web.Mvc; using System.Web.Routing; namespace RouteExample { public class RouteConfig { public static void RegisterRoutes(RouteCollection route) { route.IgnoreRoute("{resource}.axd/{*pathInfo}"); route.MapRoute( name:"Default", url:"{controller}/{action}/{id}", defaults:new { controller="Home",action="Index...

IEnumerable vs IQueryable in C#

Both are used to hold the collection of data and performing data manipulation activities. IEnumerable will retrieve all records from database and doing other data manipulation activities in client. This data can't be modified (insert/delete). IQueryable will   do data manipulation activities in database and return only the final data to client. It will give high performance. Example Assume Employee table has 1000 records. We need to retrieve only "IT" employees. *IEnumerable                  Loads all employee in memory.                  Filters "IT" employees *IQueryable                           Filters "IT" employees from database and return .

History of Asp.net core

ASP(Active Server Page ) was first introduced in 1998 for building server-side technologies. It was initially developed for creating and running dynamic, interactive web applications. It was rendering HTML(Hypertext Markup Language) on the server. It was also known as "Classic ASP" . It evolved to become Asp.net in 2002.  Asp.net includes Asp.net webforms(dynamic form-driven web applications), Asp.net MVC (more advanced web applications based on model-view-controller pattern) and Asp.net web API . Asp.net core was born in 2016. It combined the best of asp.net webforms,MVC and Web API .