Monday, February 22, 2016

Difference between TextBox and TextBoxFor:

@Html.TextBox() is loosely typed method whereas @Html.TextBoxFor() is a strongly typed (generic) extension method.
TextBox() requires property name as string parameter where as TextBoxFor() requires lambda expression as a parameter.
TextBox doesn't give you compile time error if you have specified wrong property name. It will throw run time exception.
TextBoxFor is generic method so it will give you compile time error if you have specified wrong property name or property name changes. (Provided view is not compile at run time. )

Friday, February 19, 2016

Convert List to Dataset

       public DataSet ToDataSet<T>(IList<T> list)
       {
           Type elementType = typeof(T);
           using (DataSet ds = new DataSet())
           {
               using (DataTable t = new DataTable())
               {
                   ds.Tables.Add(t);
                   //add a column to table for each public property on T
                   PropertyInfo[] _props = elementType.GetProperties();
                   foreach (PropertyInfo propInfo in _props)
                   {
                       Type _pi = propInfo.PropertyType;
                       Type ColType = Nullable.GetUnderlyingType(_pi) ?? _pi;
                       t.Columns.Add(propInfo.Name, ColType);
                   }
                   //go through each property on T and add each value to the table
                   foreach (T item in list)
                   {
                       DataRow row = t.NewRow();
                       foreach (PropertyInfo propInfo in _props)
                       {
                           row[propInfo.Name] = propInfo.GetValue(item, null) ??                                       DBNull.Value;
                       }
                       t.Rows.Add(row);
                   }
               }
               return ds;

           }

Sunday, February 14, 2016

SQL Server Languages – DML, DDL, DCL & TCL

There are mainly 4 types of language statements or commands in SQL Server.
DML
DML is abbreviation of Data Manipulation Language. It is used to retrieve, modify, add, and delete data in database.
Examples: SELECT, UPDATE, INSERT, DELETE statements
1.    SELECT – used for retrieving data from the database.
2.    UPDATE – used for modifying the data in the database.
3.    INSERT – used for adding or inserting new data into database.
4.    DELETE – used for deleting the already existing data from database.
DDL
DDL is abbreviation of Data Definition Language. It is used to create, modify and destroy the structure of database objects in database.
Examples: CREATE, ALTER, DROP, TRUNCATE  statements
1.    CREATE – used for create database objects like tables, stored procedures, functions etc.
2.    ALTER – used for modifying the existing database objects like tables, stored procedures, functions etc.
3.    DROP – used to drop or deleted the existing database objects.
4.    TRUNCATE – used to delete all the records from table and to reset identity of column to initial value.
DCL
DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.
Examples: GRANT, REVOKE statements
1.    GRANT – used for creating access permissions for users to database.
2.    REVOKE – used for revoking the already assigned permissions.
TCL
TCL is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.
Examples: COMMIT, ROLLBACK, SAVE TRANSACTION statements
1.    COMMIT – used for saving the work done in a particular transaction. For example: “Ctrl + S” in word file.
2.    ROLLBACK – used for reverting the transaction to the original state before commit. For example: “Ctrl + Z” in word file.

3.    SAVE TRANSACTION – used for setting save point in transactions.



Thursday, February 11, 2016

Difference between == and === with Example-JavaScript

This is one of the most frequently asked question in interview when one tries to judge your jQuery orJavaScript concepts.

JavaScript provides different types of operators. Here, we will be talking about strict equality andType converting equality.
Strict equality (===) means values which we are comparing must have the same type. 
This means "2" will not be equal to 2 ("2"===2 it will return false)
Type converting equality (==) means automatically it will covert variable to value irrespective of data type, either it is string or number. This means "2" will be equal to 2 ("2" == 2 it will return true)
So the double equal (==) is an auto type converting equality and three equal (===) is strict equality operator i.e it will not covert values automatically.
Difference between == and === with Example-JavaScript
Below is the demonstration with simple examples:

Demo 1

1==”1″ // it will return true because here string will converted as number
1 === “1” // it will return false because here 1 is number and “1” is string

Demo 2

0 == false // it will return true because here false is equivalent of 0
0 === false // it will return false because both are different operands
I have included the complete example for you to check the result yourself as shown below:
<!DOCTYPE HTML>
<html>
<head>
<title>Jquery - Difference between == and ===</title>
<script type="text/javascript">
function CheckDifference() {
 var val = "2";
 document.write("Value for a variable is : " +val +"<br/>"); 

 if (val == 2)
 document.write("== returns True <br/>")
 else
 document.write("== returns False <br/>")

 if (val === 2)
 document.write("=== returns True <br/>")
 else
 document.write("=== returns False <br/>")
}
</script>
</head>
<body>
<h2>JQuery or JavaScript - Difference between == and ===</h2>
<hr/>
<br/>
<div id="div1">
<input type="button" id="Check" 
 onclick="CheckDifference()" 
 value="Click to Check Difference" />
</div>
</body>
</html>

Difference between a library and a framework?

Library

library is a reusable piece of code which you use as it comes i.e it does not provide any hooks for you to extend it.

Framework

framework is a piece of code which dictates the architecture your project will follow.
Library
Framework
·         A library is a reusable piece of code which you use as it comes i.e. it does not provide any hooks for you to extend it.
·         A framework is a piece of code which dictates the architecture your project will follow.
·         A library will usually focus on a single piece of functionality, which you access through an API.
·         Once you choose a framework to work with, you have to follow the framework’s code and design methodologies.
·         You call a library function, it executes some code and then control is returned to your code.
·         The framework will provide you with hooks and callbacks, so that you build on it.
·         Library doesn’t contain framework.
·         A framework will usually include a lot of libraries to make your work easier

Thursday, February 4, 2016

SilverLight

Silverlight is a powerful cross-browser & cross-platform technology for building the next generation web experience & rich internet applications for the web.
Silverlight applications are delivered to a browser in a text-based markup language called XAML. XAML is a declarative markup language that you can use to define the UI elements for your Silverlight-based application.
Silverlight is considered as a competitor to Adobe's flash technology.
One of the design goals of the Silverlight technology is to fill the gap between windows application and web application in terms of creating Graphical User Interface (GUI). So far web developers were not able to make client happy in terms of UI, but now web developer will be able to full fill this with the help of Silverlight technology.
You can run Silverlight in most of all the popular browsers like Internet Explorer, Firefox, Chrome, Safari etc. Silverlight can run in various devices and operating systems like Windows, Apple Mac OS-X and Windows Phone 7.
Using Silverlight you can create rich, visually stunning web applications like flash. Also you can create smooth animations using Storyboards; you can stream media over the net etc.
Silverlight web browser plug-in comes as free to install (approximately 4-5 MB in size). You can download the required plug-in from Microsoft Silverlight Site.

Monday, January 25, 2016

What's the benefits of using MVVM over MVC?

The MVVM pattern provides two-way communication between the pattern parts, whereas MVC is able only to provide one-way communication. The main advantage relates to using an additional layer of non-visual parts on the Model top. It helps a developer to map data closer to the View parts.........
MVC is suitable for web apps where you can write the entire application in C# to work on a browser.  Since in MVC View is smart and knows about the model and works on the properties of the model, can even call methods of the model (using Razor) it is lot more convenient to use.
However in MVVM, Views don't have access to the real model and has only access to a special ViewModel which contains only data that can be used for UI, and is designed so that one can have different views for the same ViewModel, for example, a mobile app designed using Xamarin that can run on Andrioid, iOS, Windows Phone.
Both have their usages.  Essentially they are the same concept with slightly different flavor.  In MVVM, you dumb down model even further, so that it carries only presentation level data that can be displayed on any device and one can collect data from any device.

Sunday, January 24, 2016

difference between the Class and Interface
A Class has both definition and an implementation whereas Interface only has a definition.

A Class can be instantiated but an Interface cannot be instantiated You can create an instance of an Object that implements the Interface.

A Class is a full body entity with members, methods along with there definition and implementation. An Interface is just a set of definition that you must implement in your Class inheriting that Interface.

Tuesday, January 12, 2016

How to run Visual Studio as administrator always

Step 1 : Goto to executable of Visual studio IDE in “C:\Program Files(x86)\Microsoft Visual Studio 9.0\Common7\IDE\”, Right click on devenv.exe -> Properties -> Compatibility-> And Select “Run as Administrator” check box.
You will also need to setup for visual studio launcher.
Step 2: Go to executable of Visual Studio Launcher on “C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VsLauncher.exe” and follow same steps like step 1.

Wednesday, January 6, 2016

SqlSmash

SqlSmash Now Works With Microsoft Azure SQL Databases
 we rolled out support for Microsoft Azure Sql Databases in SqlSmash. When connected to Azure SQL, all the features should work exactly like they do with local Sql Server Databases.
A lot of companies are embracing the cloud going forward, and we want to support those of you using Microsoft’s Azure SQL platform.