Posts

Showing posts from June, 2015

What is a View?

A simple view can be thought of as a subset of a table. It can be used for retrieving data as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does the data in the view as views are the way to look at parts of the original table. The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.

What is an Index?

An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes; they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan, the SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.

What is a Linked Server?

Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query both the SQL Server databases using T-SQL Statements. With a linked server, you can create very clean, easy–to-follow SQL statements that allow remote data to be retrieved, joined and combined with local data. Stored Procedures sp_addlinkedserver, sp_addlinkedsrvlogin will be used to add new Linked Server.

Difference between Constant and Read-only ?

Constant Read-Only Value never changed. Value can be changed in the constructor of the class. Declared and Initialized in Compile time. Declared and Initialized in Run time. By default Constant is static, Cannot be declared as static. Can be declared as Static.

Difference between var and dynamic in C#?

Variables declared with  var  are implicitly but statically typed. Variables declared with  dynamic  are dynamically typed. This capability was added to the CLR in order to support dynamic languages like Ruby and Python. This means that  dynamic  declarations are resolved at run-time,  var  declarations are resolved at compile-time.  Difference Table below var dynamic Introduced in  C# 3.0 Introduced in  C# 4.0 Statically typed  – This means the type of variable declared is decided by the compiler at compile time. Dynamically typed  - This means the type of variable declared is decided by the compiler at runtime time. Need  to initialize at the time of declaration. e.g.,  var str=”I am a string”; Looking at the value assigned to the variable  str , the compiler will treat the variable  str  as string. No   need  to initialize at the time of declaration. e.g.,  dyna...

SQL SERVER – @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record

SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY() It returns the last IDENTITY value produced on a connection and by a statement in the same scope, regardless of the table that produced the value. SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than ...

What are Session state modes in ASP.NET?

ASP.NET supports different session state storage options: In-Process  is the default approach. It stores session state locally on same web server memory where the application is running. StateServer  mode stores session state in a process other than the one where application is running. Naturally, it has added advantages that session state is accessible from multiple web servers in a Web Farm and also session state will remain preserved even web application is restarted. SQLServer  mode stores session state in SQL Server database. It has the same advantages as that of StateServer. Custom  modes allows to define our custom storage provider. Off  mode disables session storage.

What are the types of Authentication in ASP.NET?

There are three types of authentication available in ASP.NET: Windows Authentication:  This authentication method uses built-in windows security features to authenticate user. Forms Authentication:  authenticate against a customized list of users or users in a database. Passport Authentication:  validates against Microsoft Passport service which is basically a centralized authentication service.

What are the different types of Validation controls in ASP.NET?

In order to validate user input, ASP.NET provides validation server controls. All validation controls inherits from BaseValidator class which contains the common validation properties and methods like  ControlToValidate , Enabled ,  IsValid ,  EnableClientScript ,  ValidationGroup , Validate()  etc. ASP.NET provides a range of validation controls: RequiredFieldValidator  validates compulsory/required input. RangeValidator  validates the range. Validates that input falls between the given range values. CompareValidator  validates or compares the input of a control with another control value or with a fixed value. RegularExpressionValidator  validates input value against a defined regular expression pattern. CustomValidator  allows to customize the validation logic with respect to our application logic. ValidationSummary  displays all errors on page collectively.

Please briefly explain the usage of Global.asax?

Global.asax is basically ASP.NET Application file. It’s a place to write code for Application-level events such as Application start, Application end, Session start and end, Application error etc. raised by ASP.NET or by HTTP Modules. There is a good list of events that are fired but following are few of the important events in Global.asax: Application_Init  occurs in case of application initialization for the very first time. Application_Start  fires on application start. Session_Start  fires when a new user session starts Application_Error  occurs in case of an unhandled exception generated from application. Session_End  fires when user session ends. Application_End  fires when application ends or time out.

Difference between Response.Redirect and Server.Transfer?

In case of Response.Redirect, a new request is generated from client-side for redirected page. It's a kind of additional round trip. As new request is generated from client, so the new URL is visible to user in browser after redirection. While in case of Server.Transfer, a request is transferred from one page to another without making a round trip from client. For the end user, URL remains the same in browser even after transferring to another page.

What is the difference between custom controls and user controls?

Custom controls are basically compiled code i.e. DLLs. These can be easily added to toolbox, so it can be easily used across multiple projects using drag and drop approach. These controls are comparatively hard to create. But User Controls (.ascx) are just like pages (.aspx). These are comparatively easy to create but tightly couple with respect to User Interface and code. In order to use across multiple projects, we need to copy and paste to the other project as well.

Abstract classes in C#

Abstract classes, marked by the keyword abstract in the class definition, are typically used to define a base class in the hierarchy. What's special about them, is that you can't create an instance of them - if you try, you will get a compile error. Instead, you have to subclass them, as taught in the chapter on inheritance, and create an instance of your subclass. So when do you need an abstract class? It really depends on what you do.  To be honest, you can go a long way without needing an abstract class, but they are great for specific things, like frameworks, which is why you will find quite a bit of abstract classes within the .NET framework it self. A good rule of thumb is that the name actually makes really good sense - abstract classes are very often, if not always, used to describe something abstract, something that is more of a concept than a real thing.  In this example, we will create a base class for four legged animals and then create a Dog class, which inherits...

Message Exchange Patterns in WCF

In Windows Communication Foundation, both parties (i.e. a service and client) communicate with each other and exchange messages using a certain pattern known as Message Exchange Pattern (MEP). WCF supports three different types of MEPs (Message Exchange Patterns). Request-Reply One-Way Duplex In this WCF Tutorial Series, we will explore all three Message Exchange Patterns step by step with the help of sample code. Request-Reply Message Exchange Pattern: Windows Communication Foundation  uses Request-Reply as default pattern for communication. In this pattern, when a service operation is called, it always generate a response message to caller (i.e. a client). The client will receive a response even if the service operation has void return type (receiving an empty SOAP body in this case). A client always waits for a reply from service for certain time (i.e.  ReceiveTimeout ) and then execute the following piece of code. Default value for...

What do you mean by three-tier architecture?

The three-tier architecture was comes into existence to improve management of code and contents and to improve the performance of the web based applications. There are mainly three layers in three-tier architecture. the are define as follows (1)Presentation  (2)Business Logic (3)Database  (1) First layer  Presentation contains mainly the interface code, and this is shown to user. This code could contain any technology that can be used on the client side like HTML, JavaScript or VBScript etc. (2) Second layer  is Business Logic which contains all the code of the server-side .This layer have code to interact with database and to query, manipulate, pass data to user interface and handle any input from the UI as well.  (3) Third layer  Data represents the data store like  MS Access ,  SQL Server , an XML file, an Excel file or even a text file containing data also some additional database are also added to that layers.  

What is JQuery?

JQuery is a light weight JavaScript library which provides fast and easy way of HTML DOM traversing and manipulation, its event handling, its client side animations, etc. One of the greatest features of jQuery is that jQuery supports an efficient way to implement AJAX applications because of its light weight nature and make normalize and efficient web programs.

What is Generics?

Generics  are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types that they store or use. A generic collection class might use a type parameter as a placeholder for the type of objects that it stores; the type parameters appear as the types of its fields and the parameter types of its methods. A generic method might use its type parameter as the type of its return value or as the type of one of its formal parameters public class Generic {     public T Field; } public static void Main() {     Generic  g = new Generic ();     g.Field = "A string";     Console.WriteLine("Generic.Field           = \"{0}\"", g.Field);     Console.WriteLine("Generic.Field.GetType() = {0}", g.Field.GetType().FullName); } Generic classes encapsulate operations that are not speci...

What are the various types of filters in an ASP.NET MVC application?

Authorization filters Action filters Result filters Exception filters

What are the features of MVC5?

Scaffolding ASP.NET Identity One ASP.NET Bootstrap Attribute Routing Filter Overrides

C# - Constructors in C# with Example, Types of Constructor in C# with Example

Constructor is a special method of a class which will invoke automatically whenever instance or object of class is created. Constructors are responsible for object initialization and memory allocation of its class. If we create any class without constructor, the compiler will automatically create one default constructor for that class. There is always at least one constructor in every class. Here you need to remember that a class can have any number of constructors and constructors don’t have any return type, not even void and within a class we can create only one static constructor. Generally constructor name should be same as class name. If we want to create constructor in a class we need to create a constructor method name same as class name check below sample method for constructor class   SampleA { public  SampleA() { Console .WriteLine( "Sample A Test Method" ); } } Types of Constructors Basically constructors are 5 types those ar...