Skip to main content

Posts

Showing posts from August, 2013

SQL Server: Cursors - Basics and Example of Cursors

SQL Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis; it’s like recordset in the ASP. SQL Server Cursor is a row base operator but cursor is not recommended because of performance issue as it create different execution plan for each rows. So one should look out for other i.e. try to implement logic with the help of while loop or CASE statement or JOIN, SELECT, GROUP etc. statements.
But few times the cursor is recommended and useful, for example if you just need to update your DB only once through Query Analyzer and don’t really bothered about performance, then cursor can be handful;
SQL Server Cursor Basics: Before jumping to example, let’s see basics of SQL Cursor statements.
Statement Description DECLARE Declare variables used in the code block SET\SELECT Initialize the variables to a specific value DECLARE CURSOR Populate the cursor with values that will be evaluated. There are an equal number of variables in the DECLARE <Name_Of…

LINQ: Understand the difference between Single vs SingleOrDefault vs First vs FirstOrDefault extension methods

Single(), SingleOrDefault(), First() and FirstOrDefault() are extension methods of the Enumerable class. “These Extension methods are static method that we can call from an instance object which implement IEnumerable interface.”
Many people get confused about the difference between Single, SingleOrDefault, First, and FirstOrDefault extension methods in LINQ.
Let’s understand the difference between all these methods:
Single(): This method searches for single instances in a collection which matching a condition. If the collection has 0 or more than one matching element, we get an exception. This method should be used if you are sure that there will exactly 1 element, for example you can use Single with primary column of an object.
SingleOrDefault(): This method returns a single, specific element in a collection, or a default value if that element is not found. If there is no matching element found then by default it’ll return null value. However this method will throw exception if there is m…

Building Responsive UI with Twitter Bootstrap and MVC4

ASP.Net MVC The Model-View-Controller (MVC) design pattern is an architectural design patterns for any standard development that separates the components of an application. This allows application to handle very flexible and extensible and easy to handle. The MVC model defines web applications with 3 logic layers: i.e. the business layer (Model logic), the display layer (View logic), and the input control (Controller logic). Check more details and you can also see working MVC sample.
Twitter Bootstrap The Twitter Bootstrap package consists of predefined CSS styles, Components and jQuery plugins. It is licensed under Apache 2.0 and is free for commercial use. Unlike most front end frameworks, Bootstrap is interesting because in addition to it being a full featured CSS framework, it adds JavaScript plugins (jQuery plugins are in the bootstrap.js file), typography, html scaffolding and components. Combined with the Plugins and responsive CSS3 based media queries; Twitter Bootstrap offers a p…