Translate

Friday, August 31, 2012

Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY

SELECT yourcolumns
FROM tablenames
JOIN tablenames
WHERE condition
GROUP BY yourcolumns
HAVING aggregatecolumn condition
ORDER BY yourcolumns

Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY

SELECT yourcolumns
FROM tablenames
JOIN tablenames
WHERE condition
GROUP BY yourcolumns
HAVING aggregatecolumn condition
ORDER BY yourcolumns

What is Session Identifier?

Session Identifier is used to identify session. It has SessionId property. When a page is requested, browser sends a cookie with a session identifier. This identifier is used by the web server to determine if it belongs to an existing session or not. If not, a Session ID (120 - bit string) is generated by the web server and sent along with the response.

Difference between Session object and Profile object in ASP.NET?


Profile
-------
1.Profile object is persistent.
2.Profile object uses the provider model to store information.
3. Profile object is strongly typed.
4. Mostly used for anonymous users.

Session 
--------
1.Session object is non-persistant.
2.Session object uses the In Proc, Out Of Process or SQL Server Mode to store information.
3. Session object is not strongly typed.
4. Used for authenticated users.

difference between Char Vs nChar Vs Varchar


Char :
Fix length memory storage
Char takes up 1 byte per character

NChar : Nchar takes Unicode data

Varchar :
Variable length memory storage
varchar rakes 1 byte for character and +2 bytes to hold length information

Difference between debug and trace


Trace statements are included by default when the program is compiled in to release build,where as debug statements are not.The Debug class is used for debugging,however, the Trace class is used for testing and optimization even after an application is compiled and released.

What is difference between interface inheritance and class inheritance

interface inheritance is a misleading term. Interface inheritance would be equivalent to the union of the method signatures of interfaces ( no typo here, an interface may implment multiple other interfaces)

Class inheritance - single hierarchy (in C#), and not only the methods are inherited, but also the data members. (interface in C# cannot define data members)

What is dataset and tell about its features. What are equivalent methods of previous, next etc. Of ADO in ADO.NET

Plz provide the answer

What are WSDL ports


 element defines an individual endpoint by specifying a single address for a binding.
Here is the grammer to specify a port:

    



  • The port element has two attributes - the name attribute and the binding attribute.
  • The name attribute provides a unique name among all ports defined within in the enclosing WSDL document.
  • The binding attribute refers to the binding using the linking rules defined by WSDL.
  • Binding extensibility elements (1) are used to specify the address information for the port.
  • A port MUST NOT specify more than one address.
  • A port MUST NOT specify any binding information other than address information.

What is the difference between session state and session variables

Plz give your answer

What are the different types of caching?

Output Caching: Output caching is useful when the contents of an entire page can be cached. While a page is cached by the output cache, subsequent requests for that page are served from the output page without executing the code that created it.

Fragment Caching: Sometimes it is not practical to cache an entire page - perhaps portions of the page must be created or customized for each request. In this case, it is often worthwhile to identify objects or data that are expensive to construct and are eligible for caching. Once these items are identified, they can be created once and then cached for some period of time. Additionally, fragment caching can be used to cache regions of a page's output.

Data Caching: Data caching is storing data in memory for quick access. Typically information that is costly to obtain (in terms of performance) is stored in the cache. One of the more common items stored in a cache is commonly displayed database values; by caching such information, rather than relying on repeated database calls, the demand on the Web server and database server's system resources are decreased and the Web application's scalability increased. The cache items can be given an expiration policy that causes them to be removed from the cache when they have expired. Code that accesses the cache item simply checks for the absence of the item and recreates it, if necessary.

Thursday, August 30, 2012

what are the advantages of hosting WCF Services in IIS as compared to self-hosting?

There are two main advantages of using IIS over self-hosting:-
Automatic activation
IIS provides automatic activation that means the service is not necessary to be running in
advance. When any message is received by the service it then launches and fulfills the request.
But in case of self hosting the service should always be running.
Process recycling
If IIS finds that a service is not healthy that means if it has memory leaks etc, IIS recycles the
process. For every browser instance, a
worker process is spawned and the request is serviced. When the browser disconnects the worker,
process stops and you loose all information. IIS also restarts the worker process. By default, the
worker process is recycled at around 120 minutes. So why does IIS recycle. By restarting the
worker process it ensures any bad code or memory leak do not cause issue to the whole system.
In case of self-hosting both the above features, you will need to code yourself. Lot of work
right!!.

How to generate proxy for WCF Services?

The proxy can be generated using Visual Studio by right clicking Reference and clicking on Add Service Reference. This brings up the Add Service Reference dialog box, where you need to supply the base address of the service (or a base address and a MEX URI) and the namespace to contain the proxy.
Proxy can also be generated by using SvcUtil.exe command-line utility. We need to provide SvcUtil with the HTTP-GET address or the metadata exchange endpoint address and, optionally, with a proxy filename. The default proxy filename is output.cs but you can also use the /out switch to indicate a different name.
SvcUtil http://localhost/MyService/MyService.svc /out:Proxy.cs
When we are hosting in IIS and selecting a port other than port 80 (such as port 88), we must provide that port number as part of the base address:
SvcUtil http://localhost:88/MyService/MyService.svc /out:Proxy.cs

What are SOAP Faults in WCF?

Common language runtime (CLR) exceptions do not flow across service boundaries. At the maximum, a CLR exceptions may propagate up to the service tier from business components. Unhandled CLR exceptions reach the service channel and are serialized as SOAP faults before reporting to clients. An unhandled CLR exception will fault the service channel, taking any existing sessions with it. That is why it is very importatnt to convert the CLR exceptions into SOAP faults. Where possible, throw fault exceptions

What is the proxy for WCF Service?

A proxy is a class by which a service client can Interact with the service.
By the use of proxy in the client application we are able to call the different methods exposed by the service

What are the types of contract available in WCF?

The main contracts are:
a)Service Contract:Describes what operations the client can perform.
b)Operation Contract : defines the method inside Interface of Service.
c)Data Contract:Defines what data types are passed
d)Message Contract:Defines wheather a service can interact directly with messages

In WCF which bindings supports the reliable session?

In WCF, following bindings supports the reliable session - 

1. wsHttpBinding 
2. wsDualHttpBinding 
3. wsFederationHttpBinding 
4. netTcpBinding 

What are the advantages of hosting WCF service in WAS?

WAS (Windows Activation Service) is a component of IIS 7.0. Following are few advantages : 

1. We are not only limited to HTTP protocol. We can also use supported protocols like TCP, named pipes and MSMQ 

2. No need to completely install IIS. We can only install WAS component and keep away the WebServer. 

What is service host factory in WCF?

1. Service host factory is the mechanism by which we can create the instances of service host dynamically as the request comes in. 
2. This is useful when we need to implement the event handlers for opening and closing the service. 
3. WCF provides ServiceFactory class for this purpose. 

What are the core security features that WCF addresses?

There are four core security features that WCF addresses:-

Confidentiality: This feature ensures that the information does not go in wrong hands when it travels from the sender to the receiver.

Integrity: This feature ensures that the receiver of the message gets the same information that the sender sends without any data tampering. 

Authentication: This feature verifies who the sender is and who the receiver is. 

Authorization: This feature verifies whether the user is authorized to perform the action they are requesting from the application.


What the different transaction options ?

There are three transaction option in wcf :

TransactionFlowOption.NotAllowed

This is a default option. Using this option no transaction will be propagated across the binding. If any client attempts to call the WCF service in a transaction it will be ignored for this option.

TransactionFlowOption.Allowed

This option specifies that client can call this WCF service in a transaction. It’s not compulsory that the service needs to be called in a transaction. You can call without the transaction also.

TransactionFlowOption.Mandatory

This option specifies that client must call the WCF service in a transaction mode. If the WCF service is called without transaction, ‘FaultException’ will be raised.

What are the major differences between services and Web services? OR What is the difference WCF and Web services?

Web services can only be invoked by HTTP. While Service or a WCF component can be invoked by any protocol and any transport type. Second web services are not flexible. However, Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.

What is wcf ?

The Windows Communication Foundation (or WCF), previously known as "Indigo", is a runtime and a set of APIs (application programming interface) in the .NET Framework for building connected, service-oriented applications.


What are ends, contracts, address and bindings?


• Contract (What)Contract is an agreement between two or more parties. It defines the protocol how client should communicate with your service. Technically, it describes parameters and return values for a method.
 

• Address (Where)An Address indicates where we can find this service. Address is a URL, which points to the location of the service.
 

• Binding (How)Bindings determine how this end can be accessed. It determines how communications is done. For instance, you expose your service, which can be accessed using SOAP over HTTP or BINARY over TCP. So for each of these communications medium two bindings will be created.
Below figure, show the three main components of end. You can see the stock ticker is the service class, which has an end hosted on www.soa.com with HTTP and TCP binding support and using Stock Ticker interface type.
 

constructor chaining

where a constructor calls another constructor in its class using the ": this()" designation as 


public Test( bool a, int b, string c )
    : this( a, b )
{
    this.m_C = c;
}
public Test( bool a, int b, float d )
    : this( a, b )
{
    this.m_D = d;
}
private Test( bool a, int b )
{
    this.m_A = a;
    this.m_B = b;
}

Basically constructor chaining is where a subclass calls its superclasses constructor which subsequentally calls its superclasses constrctor and so on.

Difference between # and ## in sql server ?


#table refers to a local (visible to only the user who created it) temporary table.

##table refers to a global (visible to all users) temporary table.

Wednesday, August 29, 2012

What is the difference between user and custom controls?


User controls are easier to create whereas custom controls require extra effort.
User controls are used when the layout is static whereas custom controls are used in dynamic layouts.
A user control cannot be added to the toolbox whereas a custom control can be.
A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.

Why don’t we have multiple inheritance in .NET?


There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.

HttpContext


HttpContext object will hold information about the current http request. HttpContext object will be constructed newly for every request given to an ASP.Net application and this object will hold current request specific informations like Request, Response, Server, Session, Cache, User and etc. For every request, a new HttpContext object will be created which the ASP.Net runtime will use during the request processing. A new HttpContext object will be created at the beginning of a request and destroyed when the request is completed.
One of the best features of HttpContext object is using its Item Collection.

Array


An array is a fixed collection of same-type data that are stored contiguously.
Arrays are declared much like variables, with a set of [] brackets after the data type, like this: 

You need to instantiate the array to use it, which is done like this: 

string[] names = new string[2];

Differrence between Array.CopyTo() and Array.Clone()

Both CopyTo() and Clone() make shallow copy (data is copied) and used for Single Dimension arrays.

Clone() method makes a clone of the original array. It returns an exact length array.

CopyTo()
 copies the elements from the original array to the destination array starting at the specified destination array index. Note that, this adds elements to an already existing array.

Difference between delete and truncate in sql server?

TruncateDelete
TRUNCATE is a DDL commandDELETE is a DML command
TRUNCATE TABLE always locks the table and page but not each rowDELETE statement is executed using a row lock,                                             each row in the table is locked for deletion
Cannot use Where ConditionWe can specify filters in where clause
It Removes all the dataIt deletes specified data if where condition exists.
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.Delete activates a trigger because the operation                                are logged individually.
Faster in performance wise, because it is minimally logged in transaction log.Slower than truncate because, it maintain logs for every record
 Drop all object’s statistics and marks like High Water Mark free extents and leave the object really empty with the first extent. zero pages are left in the tablekeeps object’s statistics and all allocated space. After a                       DELETE statement is executed,the table can still contain empty pages.
TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction loThe DELETE statement removes rows one at a time                       and records an entry in the transaction log for each deleted row
If the table contains an identity column, the counter for that column is reset to the seed value that is defined for the columnDELETE retain the identity
Restrictions on using Truncate Statement
1. Are referenced by a FOREIGN KEY constraint.
2. Participate in an indexed view.
3. Are published by using transactional replication or merge replication.
Delete works at row level, thus row level constrains apply

What is the difference between stored procedure and function.

1) Stored procedure are compiled for first time and compiled format is saved and executes compiled code when ever it is called. But function is compiled and executed every time it is called. 

2) Function must return a value but in stored procedure it is optional. 

3) Function takes one input parameter it is mandatory but stored procedure may take o to n input parameters.

4) Functions can be called from select statement, but stored procedures can not be called from select statement. 

5) We can use try catch statements in stored procedures but in functions we can not use.

6) We can not use insert,delete,update and create statements in functions but in stored procedures we can use those statements. 

7 ) Functions can have only input parameters but stored procedure can have input and out put parameters

What is Singleton ?


Singleton class is a class whose only one object can be created at a time
Singleton provides a global, single instance by:

·  Making the class create a single instance of itself.

·  Allowing other objects to access this instance through a class method that returns a reference to the instance. A class method is globally accessible.

·   Declaring the class constructor as private so that no other object can create a new instance.

Singleton results in the following benefits and liabilities:

               Benefits

·   Instance control. Singleton prevents other objects from instantiating their own copies of the Singleton object, ensuring that all objects access the single instance.

·   Flexibility. Because the class controls the instantiation process, the class has the flexibility to change the instantiation process.

Liabilities

·   Overhead. Although the amount is minuscule, there is some overhead involved in checking whether an instance of the class already exists every time an object requests a reference. This problem can be overcome by using static initialization as described in Implementing Singleton in C#.

·   Possible development confusion. When using a singleton object (especially one defined in a class library), developers must remember that they cannot use the new keyword to instantiate the object. Because application developers may not have access to the library source code, they may be surprised to find that they cannot instantiate this class directly.

·   Object lifetime. Singleton does not address the issue of deleting the single object. In languages that provide memory management (for example, languages based on the .NET Framework), only the Singleton class could cause the instance to be deallocated because it holds a private reference to the instance. In languages, such as C++, other classes could delete the object instance, but doing so would lead to a dangling reference inside the Singleton class.

What is Indexer ?


Indexer : Indexers allow your class to be used just like an array.
·         Indexer Concept is object act as an array.
Indexer an object to be indexed in the same way as an array.
·         Indexer modifier can be private, public, protected or internal.
·         The return type can be any valid C# types.
·         Indexers in C# must have at least one parameter. Else the compiler will generate a compilation error.

this [Parameter]
{
    get
    {
        // Get codes goes here
    }
    set
    {
        // Set codes goes here
    }

For Example:

using System;
using System.Collections.Generic;
using System.Text;

namespace Indexers
{
    class ParentClass
    {
        private string[] range = new string[5];
        public string this[int indexrange]
        {
            get
            {
                return range[indexrange];
            }
            set
            {
                range[indexrange] = value;
            }
        }
    }

    /* The Above Class just act as array declaration using this pointer */

    class childclass
    {
        public static void Main()
        {
            ParentClass obj = new ParentClass();

            /* The Above Class ParentClass  create one object name is obj */

            obj[0] = "ONE";
            obj[1] = "TWO";
            obj[2] = "THREE";
            obj[3] = "FOUR ";
            obj[4] = "FIVE";
            Console.WriteLine("WELCOME TO C# CORNER HOME PAGE\n");
            Console.WriteLine("\n");

            Console.WriteLine("{0}\n,{1}\n,{2}\n,{3}\n,{4}\n", obj[0], obj[1], obj[2], obj[3], obj[4]);
            Console.WriteLine("\n");
            Console.WriteLine("ALS.Senthur Ganesh Ram Kumar\n");
            Console.WriteLine("\n");
            Console.ReadLine();
        }
    }
}

Why we use property in c#? (get, set)


Properties are a way to control access to your private members. It simply (set) copies the given value to the private member and (get) returns the private member without modifying it. Often, the set part is used to check the given value in order to avoid later errors, or to simplify code

private string myString = "";

public string MyString
{
set
{ if ( value == null )
{value = "";}
myString = value;
}
}

Document Object Model (DOM)


The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents
The DOM is separated into 3 different parts / levels:


  • Core DOM - standard model for any structured document
  • XML DOM - standard model for XML documents
  • HTML DOM - standard model for HTML documents
What is the XML DOM?
  • A standard object model for HTML
  • A standard programming interface for HTML
  • Platform- and language-independent
  • A W3C standard
All XML Elements Must Have a Closing TagXML Tags are Case SensitiveXML Elements Must be Properly NestedXML Documents Must Have a Root Element
    .....
  • The entire document is a document node
  • Every HTML element is an element node
  • The text in the HTML elements are text nodes
  • Every HTML attribute is an attribute node
  • Comments are comment nodes
DOM Example                    DOM Lesson one     Hello world!   The HTML DOM Node Tree
  • x.innerHTML - the text value of x
  • x.nodeName - the name of x
  • x.nodeValue - the value of x
  • x.parentNode - the parent node of x
  • x.childNodes - the child nodes of x
  • x.attributes - the attributes nodes of x

  • x.getElementById(id) - get the element with a specified id
  • x.getElementsByTagName(name) - get all elements with a specified tag name
  • x.appendChild(node) - insert a child node to x
  • x.removeChild(node) - remove a child node from x


The XML DOM defines the objects and properties of all XML elements, and the methods (interface) to access them.
What is the HTML DOM?
The HTML DOM is:
The HTML DOM defines the objects and properties of all HTML elements, and the methods(interface) to access them.

 

DOM Nodes
According to the DOM, everything in an HTML document is a node.
The DOM says:
Look at the following HTML document:


The HTML DOM views an HTML document as a tree-structure. The tree structure is called a node-tree.
All nodes can be accessed through the tree. Their contents can be modified or deleted, and new elements can be created.

The programming interface of the DOM is defined by standard properties and methods.
Properties are often referred to as something that is (i.e. the name of a node).
Methods are often referred to as something that is done (i.e. remove a node).

HTML DOM Properties
Some DOM properties:
Note: In the list above, x is a node object (HTML element).

HTML DOM Methods
Some DOM methods:
Note: In the list above, x is a node object (HTML element).

What is the difference between Finalize() and Dispose()?


Dispose() is called by as an indication for an object to release any unmanaged resources it has held. 
Finalize() is used for the same purpose as dispose however finalize doesn’t assure the garbage collection of an object. 
Dispose() operates determinalistically due to which it is generally preferred.

What is N-tire Architecture ?


The n-Tier application has three tiers or layers; they are called the presentation layer, the business layer and the data layer. Each layer interacts with the layer directly below, and has specific function to perform. The presentation layer is responsible for displaying the user interface to the end user. The programmer uses this layer for designing the user interface and to transfer data. In ASP.NET, ASPX pages, user controls, server controls and sometimes security related classes and objects are used to support the presentation layer.
The business layer works as a go-between to transfer the data from presentation layer. In the three-tier architecture, the data access layer does not interact directly with the presentation layer. The architecture in ASP.NET includes using SqlClient or OleDb objects to retrieve, update and delete data from SQL Server or other databases and passing the data retrieved to the presentation layer in a DataReader or DataSet object, or a custom collection object. The data layer gets the data from the business layer and sends it to the database or vice versa.

The main advantage of using n-Tier is that the complexity associated with the business and the process is reduced and is easy to implement. The elements of performance, scalability and future development issues need to be considered when deciding on the architecture of the application.

What is X-Path?

XPath, the XML Path Language, is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers, or Boolean values) from the content of an XML document.

XPath is a language for finding information in an XML document.

What is the meaning of XBRL??


XBRL (Extensible Business Reporting Language) is an XML-based computer language for the electronic transmission of business and financial data. The goal of XBRL is to standardize the automation of business intelligence (BI).
XBRL is an open standard which is overseen by a not-for-profit organization called XBRL International. XBRL uses tags to describe and identify each item of data in an electronic document. The tags allow computer programs to sort through data and analyze relationships quickly and generate output in various formats. Because the tags are standardized, analysis can be conducted across multiple documents from multiple sources, even if the text in the documents is written in different languages.

Difference between CDATA and PCDATA in XML ?


PCDATA - Parsed Character Data :
 

XML parsers normally parse all the text in an XML document.
PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded. 
CDATA - (Unparsed) Character Data :
The term CDATA is used about text data that should not be parsed by the XML parser.Characters like "<" and "&" are illegal in XML elements.
CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.