Posts

what is the difference between declarative and imperative programming

A great C# example of declarative vs. imperative programming is LINQ. With  imperative  programming, you tell the compiler what you want to happen, step by step. For example, let's start with this collection, and choose the odd numbers: List <int> collection = new List <int> { 1 , 2 , 3 , 4 , 5 }; With imperative programming, we'd step through this, and decide what we want: List <int> results = new List <int> (); foreach ( var num in collection ) {     if ( num % 2 != 0 )           results . Add ( num ); } Here, we're saying: Create a result collection Step through each number in the collection Check the number, if it's odd, add it to the results With  declarative  programming, on the other hand, you write code that describes what you want, but not necessarily how to get it (declare your desired results, but not the step-by-step): var results = collection . Whe...

Using SQL Profiler

Image
Goto Sql Server Management Studio. Tools - >Sql Server Profiler Click on "OK" and enjoy.

Difference between WCF and Web service

Difference between WCF and Web service Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them. Features Web Service WCF Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service Programming [WebService] attribute has to be added to the class [ServiceContraact] attribute has to be added to the class Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client Operation One-way, Request- Response are the different operations supported in web service One-Way, Request-Response, Duplex are different type of operations supported in WCF XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespac...

Useful SQL shortcuts

Move content to right  CTRL +A & TAB Move content to left  CTRL +A & SHIFT + TAB Convert text to UPPER CASE in sql editor select the content and press CTRL+SHIFT+U Convert text to LOWER CASE in sql editor select the content and press  CTRL+SHIFT+L . . . . . . . . . . .

Creating Custom HTML Helpers

Creating custom html code blocks which can be re-used in the entire project. Step1: Add a folder "App_Code" in the root directory. Step2: Add a .cshtml file in the App_Code folder "CustomHelpers.cshml"    @helper   HomeHelper(){         <h1>Home Page Helper</h1>     } Step3: Call the newly added helper code in our existing .cshtml page @{     ViewBag.Title = "Home Page";     Layout = "~/Views/Shared/_Layout.cshtml"; } <h2> Home Page</h2> <div>     @CustomHelper.HomeHelper(); </div>

ASP.NET Routing

Introduction In an ASP.NET application that does not use routing, an incoming request for a URL typically maps to a physical file that handles the request, such as an .aspx file. For example, a request for  http://server/application/Products.aspx?id=4  maps to a file that is named Products.aspx that contains code and markup for rendering a response to the browser. The Web page uses the query string value of  id=4  to determine what type of content to display. In ASP.NET routing, you can define URL patterns that map to request-handler files, but that do not necessarily include the names of those files in the URL. In addition, you can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string. URL Patterns in MVC Applications URL patterns for routes in MVC applications typically include  {controller}  and  {action}  placeholders. When a request is rec...

Features of the ASP.NET MVC Framework

The ASP.NET MVC framework provides the following features: Separation of application tasks (input logic, business logic, and UI logic), testability, and test-driven development (TDD). All core contracts in the MVC framework are interface-based and can be tested by using mock objects, which are simulated objects that imitate the behavior of actual objects in the application. You can unit-test the application without having to run the controllers in an ASP.NET process, which makes unit testing fast and flexible. You can use any unit-testing framework that is compatible with the .NET Framework. An extensible and pluggable framework. The components of the ASP.NET MVC framework are designed so that they can be easily replaced or customized. You can plug in your own view engine, URL routing policy, action-method parameter serialization, and other components. Extensive support for ASP.NET routing, which is a powerful URL-mapping component that lets you build applications that have compr...