tag:blogger.com,1999:blog-26963725990294909032024-03-14T07:46:10.910+05:30Dot Net Interview Cracker - A comprehensive list of Dot Net Interview QuestionsDot Net Interview Cracker provides a wide-ranging list of Dot Net (C#, ASP.NET, ADO.NET, SQL) Interview Questions and Answers that will help you face toughest of the programming interviews comfortably.
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.comBlogger161125tag:blogger.com,1999:blog-2696372599029490903.post-19908892178720784332015-10-28T14:00:00.002+05:302015-10-28T14:16:06.462+05:30Microsoft SQL Server Interview Questions<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="text-align: justify;">
<div align="JUSTIFY" style="line-height: 0.34cm; margin-bottom: 0cm; orphans: 1;">
<div align="JUSTIFY" style="line-height: 0.34cm; margin-bottom: 0cm; orphans: 1;">
<div align="JUSTIFY" style="line-height: 0.34cm; margin-bottom: 0cm; orphans: 1;">
<div align="JUSTIFY" style="line-height: 0.34cm; margin-bottom: 0cm; orphans: 1;">
<div align="JUSTIFY" style="line-height: 0.34cm; margin-bottom: 0cm; orphans: 1;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">SQL
Server Interview Questions has lots of latest and important SQL
interview questions which consist of not only theoretical
explanations but most essentially its practical implementations.</span></span></span></span></div>
<div align="JUSTIFY" style="line-height: 0.34cm; margin-bottom: 0cm; orphans: 1;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><br /><span style="background: #ffffff;">This
book is an indispensable resource for Microsoft .Net Developers. It
will serve as a useful resource to anyone who faces interviews in SQL
(developers of any platform - JAVA, C++, etc), as well as
Database Administrators.</span></span></span><br />
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="background: #ffffff;"><br /></span></span></span></div>
</div>
</div>
</div>
</div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitDUN8cX0GU2pXlqudFDz3Exq2mzPCyvb17yQ08lgTsr2JPaogIpQ0oxA5OA2Z2StcnnMY1fr-Je-WMmWkfzllLJjyYq5r3t84S74BPnIuUCgA6yyw9_COvZZmSIQdJ3yZQg4z3ykBDEc/s1600/Sample-EBook+Cover.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitDUN8cX0GU2pXlqudFDz3Exq2mzPCyvb17yQ08lgTsr2JPaogIpQ0oxA5OA2Z2StcnnMY1fr-Je-WMmWkfzllLJjyYq5r3t84S74BPnIuUCgA6yyw9_COvZZmSIQdJ3yZQg4z3ykBDEc/s640/Sample-EBook+Cover.jpg" width="390" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="line-height: 0.34cm; orphans: 1;">
<span style="color: #666666; font-family: Arial, sans-serif;">The
list of topics included in the very first edition of the E-Book is as
given below:</span></div>
<div style="line-height: 0.34cm; orphans: 1;">
<span style="color: #666666; font-family: Arial, sans-serif;"><br /></span></div>
<div align="LEFT" style="margin-bottom: 0cm; orphans: 1;">
</div>
<ul>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between SQL Server 2008 and SQL Server 2012</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between Data Definition Language (DDL) and Data Manipulation Language
(DML)</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the six main categories of SQL commands?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are unique identifiers in SQL Server?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is Null Constraint?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is check constraint in SQL SERVER?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is default constraint?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is a database key?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the different types of keys in SQL</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between Primary Key and Unique Key</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between Primary Key and Candidate Key</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between Primary Key and Foreign Key</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is Identity Column in Table?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
can you insert explicit values in an identity column of a table?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the syntax to check current identity of a table?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Can
we change identity key values for a table or reset the identity key
value?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the maximum allowable size of a row in SQL SERVER?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the Sparse Columns in SQL Server 2008</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Describe
the characteristics of Sparse Columns</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">List
down the limitations for using SPARSE Columns</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
a column is changed from sparse to nonsparse or nonsparse to sparse?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the data types which cannot be specified as SPARSE?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the COLUMNS_UPDATED function and its relation to Sparse Column</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the different types of data types in SQL Server?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the use of different types of integer data types in SQL?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is times stamp data type is SQL Server?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
can you generate duplicate rowversion values?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
Where Clause?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is select statement in TSQL?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the Logical Processing Order of the SELECT statement</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the Join in SQL Server? What are the different types of join?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the basic difference in joins in SQL Server 2000 and 2005?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is a view in SQL server?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is common table expression (CTE)?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">When
should you use a Common Table Expression?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Define
the Structure of a CTE with example</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
recursive Common Table Expressions</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is a table variable?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between local and global temporary tables in SQL</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the Ranking Functions in SQL in detail</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is stored procedure?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Is
nesting possible in stored procedure? If yes how many number of
times?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the maximum amount of parameters a Stored Procedure can have?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
can you improve performance of a Stored Procedure?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between a Stored Procedure and a User-defined Function</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between @@IDENTITY, SCOPE_IDENTITY, IDENT_CURRENT in SQL</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the Inclusive nature of BETWEEN operator in SQL</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Differentiate
between DELETE and TRUNCATE commands in SQL</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
Indexes in SQL Server</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the data types on which indexes cannot be created?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the Index Structures in SQL Server</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the Index Types in SQL Server</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the circumstances when Indexes should be avoided / used</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is Normalization?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the various Normal forms</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is a SQL Transaction?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the SQL Server transaction modes?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the properties of transactions.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the four Transactional Control Commands (TCC)?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is a Shadow table?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
do you create a Shadow table in SQL?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
are the drawbacks of a SQL Cursor?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Write
a SQL query to list all the tables in a database.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Write
a SQL query to list all the stored procedures in a database.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Write
a SQL query to list all the user defined functions in a database.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Write
a SQL query to list all the views in a database.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Write
a SQL query to list all the constraints in a database.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Write
a SQL query to list all the indexes created for a particular table
(say common_user).</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
PIVOT and UNPIVOT operators in SQL</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is an Inline View?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the SQL CASE expression in detail.</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
do you tune SQL Indexes for better performance?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">How
do you tune SQL queries for better performance?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Explain
the use of FOR XML in SQL Queries</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the use of TYPE directive in FOR XML queries?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">What
is the use of ROOT directive in FOR XML queries?</span></i></li>
<li><i style="font-family: Arial, sans-serif;"><span style="color: #666666;">Frequently
asked SQL Queries in interviews</span></i></li>
</ul>
<div align="JUSTIFY" style="line-height: 0.53cm; margin-bottom: 0cm; orphans: 1;">
<span style="font-family: Arial, sans-serif;"><span style="color: #666666;">SQL
Server Interview Questions E-Book is</span> </span><b style="font-family: Arial, sans-serif; font-size: x-large; text-align: left;">now available for sale</b><span style="font-family: Arial, sans-serif; font-size: large; text-align: left;">.</span></div>
<br />
<div style="text-align: center;">
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><b>INSTANT DOWNLOAD AFTER FULL PAYMENT</b></span></span></span></span></div>
</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="hosted_button_id" type="hidden" value="HT7G8FDGZZUQW" />
<input alt="PayPal – The safer, easier way to pay online." border="0" name="submit" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynowCC_LG.gif" type="image" />
<img alt="" border="0" height="1" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" /></form>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><u><b>Details of the EBook</b></u></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><b>Name</b>: </span><span style="font-family: Arial, sans-serif; font-size: 18px; line-height: 20.7px; text-align: justify;">SQL Server Interview Questions</span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><b>Author</b>: Chandan Sinha</span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><b>Format</b>: PDF</span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><b>Language</b>: English</span></span><br />
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><u><b>Price</b>: <b>$2.99 (Exclusively on this website)</b></u></span></span></span><br />
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><u><b><br /></b></u></span></span></span>
<span style="color: red;"><span style="font-family: Arial, sans-serif;">(<b>Limited Period Offer</b> - Rates slashed from <b>$3.99</b> to <b>$2.99</b>)</span></span><br />
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><b>Focus Area</b>: Technical Interview in Microsoft SQL Server</span></span></div>
<br />
<h1 class="western">
<span style="font-family: Arial, sans-serif;"><a href="http://www.amazon.com/gp/product/B00ONQGUF6" target="_blank">SQL Server Interview Questions</a></span></h1>
<div>
<a href="http://www.amazon.com/gp/product/B00ONQGUF6" target="_blank"><span style="font-family: Arial, Helvetica, sans-serif;"><b>[Kindle Edition]</b></span></a></div>
<h1 class="western">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Ebook Link on Amazon Kindle - <a href="http://www.amazon.com/gp/product/B00ONQGUF6" target="_blank">http://www.amazon.com/gp/product/B00ONQGUF6</a></span></span></h1>
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-63656448341252216732015-06-16T17:44:00.003+05:302015-06-16T17:46:19.035+05:30PIVOT - UNPIVOT operator<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Explain
PIVOT and UNPIVOT operators in SQL</b></span></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">PIVOT
and UNPIVOT are relational operators which were introduced in SQL
Server 2005. These operators allow easy transformation of
table-valued expression into another table.</span></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">PIVOT
allows you to rotate rows into columns during the execution of an SQL
Query. It performs an aggregation, and merges possible multiple rows
into a single row in the output.</span></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">UNPIVOT
does almost the opposite of PIVOT operator by rotating columns into
rows, but it is not exactly opposite. PIVOT merges multiple rows into
single while UNPIVOT fails to reproduce the original table due to the
merged rows. Null input values to UNPIVOT disappear in its output.</span></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>A
simple example of PIVOT operator</b></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Suppose
we have a <b>dbo.currency_rate</b> table which consists of three
columns - in_currency_id, mn_rate and dt_currency.</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: green;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">--
Create table</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">CREATE</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">TABLE</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">in_currency_id</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">int</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">mn_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">money</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dt_currency</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">datetime</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: green;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">--
Insert data in table</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">1</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
60.15</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-15
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">2</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
35.57</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-15
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">3</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
78.90</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-15
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">4</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
87.15</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-15
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">1</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
10.18</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-16
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">2</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
11.25</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-16
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">3</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
08.48</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-16
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INSERT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">VALUES
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">4</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
18.31</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: red;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">'2015-06-16
09:59:16.640'</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: green;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">--
Select and confirm the data before any operation</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">SELECT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">*</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FROM</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">dbo</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">currency_rate</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><b>in_currency_id mn_rate dt_currency</b></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">1 60.15 2015-06-15
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">2 35.57 2015-06-15
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">3 78.90 2015-06-15
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">4 87.15 2015-06-15
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">1 10.18 2015-06-16
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">2 11.25 2015-06-16
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">3 8.48 2015-06-16
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;">4 18.31 2015-06-16
09:59:16.640</span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><b>Use
PIVOT operator to transform rows into columns:</b></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="color: green;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">--
Pivot table with two rows and five columns</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">SELECT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">*</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FROM</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[dbo]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[currency_rate]</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;"><b>PIVOT</b></span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: black;"> </span><span style="color: magenta;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">AVG</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">mn_rate</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FOR</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[in_currency_id]</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">IN</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[1]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[2]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[3]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[4]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">AS</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">pivot_table</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">;</span></span></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>Output:</b></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>dt_currency 1 2 3 4</b></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
2015-06-15
09:59:16.640 60.15 35.57 78.90 87.15</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
2015-06-16
09:59:16.640 10.18 11.25 8.48 18.31</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<br />
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>A
simple example of UNPIVOT operator</b></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">In
continuation with the PIVOT operator example, save the result of the
PIVOT operator in a temporary table:</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">SELECT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">*</span></span></span></div>
<div style="margin-bottom: 0cm;">
<b><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">INTO</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">#tmp_pivot_table</span></span></span></b></div>
<div style="margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FROM</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[dbo]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">.</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[currency_rate]</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;"><b>PIVOT</b></span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: black;"> </span><span style="color: magenta;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">AVG</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">mn_rate</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FOR</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[in_currency_id]</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">IN</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[1]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[2]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[3]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[4]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">AS</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">pivot_table</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">;</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Use
UNPIVOT operator to transform rows into columns:</b></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">SELECT</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[dt_currency]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[in_currency_id]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[mn_rate]</span></span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FROM</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">#tmp_pivot_table</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;"><b>UNPIVOT</b></span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: black;"> </span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">mn_rate</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">FOR</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">in_currency_id</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">IN</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">(</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[1]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[2]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[3]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">,</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">[4]</span></span></span><span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: grey;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">)</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: blue;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">AS</span></span></span><span style="color: black;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">
</span></span></span><span style="color: teal;"><span style="font-family: Consolas, sans-serif;"><span style="font-size: x-small;">unpivot_table</span></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Output:</b></span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">dt_currency in_currency_id mn_rate</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-15
09:59:16.640 1 60.15</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-15
09:59:16.640 2 35.57</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-15
09:59:16.640 3 78.90</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-15
09:59:16.640 4 87.15</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-16
09:59:16.640 1 10.18</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-16
09:59:16.640 2 11.25</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-16
09:59:16.640 3 8.48</span></span></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">2015-06-16
09:59:16.640 4 18.31</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-75382261919859776052014-05-08T15:29:00.001+05:302015-10-28T14:00:59.269+05:30.Net Framework - Quick Reference Guide<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
<b>.Net Framework E-Book</b> by the .Net Interview Cracker is a very
useful resource for developers and serves well as a quick reference
guide. This E-Book prepares them for <b>technical interviews in Microsoft .Net Framework.</b>.</span></span></div>
</div>
<div style="margin-bottom: 0in;">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZucjVvkB-qLX5aSxtdlROmmXY32HGjrCJJn6kr_OkXKH9lfCxEB_uSaYwCDoZVsFcLq5MqHEbZgoKB_cTWy1Dl05gGPZBbVM76hXFzjDAyE08cxrtirNFJKc1VsPg4wb1U3GWmWNmFPU/s1600/DotNetFramework2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt=".Net Framework EBook for Technical Interviews" border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZucjVvkB-qLX5aSxtdlROmmXY32HGjrCJJn6kr_OkXKH9lfCxEB_uSaYwCDoZVsFcLq5MqHEbZgoKB_cTWy1Dl05gGPZBbVM76hXFzjDAyE08cxrtirNFJKc1VsPg4wb1U3GWmWNmFPU/s1600/DotNetFramework2.jpg" title=".Net Framework EBook for Technical Interviews" width="540" /></a></div>
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
list of topics included in the very first edition of the E-Book is as
given below:</span></span></div>
<div style="margin-bottom: 0in;">
</div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">What
is .NET Framework?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Explain
the architecture of .Net Framework</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Common
Language Runtime (CLR)</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Features
of the Common Language Runtime</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Dynamic
Language Runtime</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Common
Language Infrastructure (CLI)</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">What
is Intermediate Language (IL)?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">How
is a C# program compiled to a processor specific native code?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Explain
the services provided by the .Net Framework</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Assembly</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Properties
of an Assembly</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Components
of an Assembly</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">What
is an Assembly Manifest?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Functions
of the Assembly Manifest</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Contents
of the Assembly Manifest</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Differentiate
between Single-file assembly and Multifile assembly</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">What
are the different types of assemblies in .NET</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Friend
Assemblies</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Differentiate
between Static and Dynamic Assemblies</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Hub-and-Spoke
model & Satellite Assemblies</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">What
is DLL Hell?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Application
Domains</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Garbage
Collection</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Garbage
Collection in detail</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Conditions
for a garbage collection</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Benefits
provided by Garbage Collection</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Is
the execution of the Garbage Collector non-deterministic? If yes,
why?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">How
can you instruct the garbage collector to collect unreferenced data?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">How
can you force Garbage Collection?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Global
Assembly Cache (GAC)</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Mention
the demerits of installation of an assembly in the GAC</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Mention
the benefits of installation of an assembly in the GAC</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Mention
the ways to deploy an assembly into the GAC</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Where
is the GAC located?</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Enumerate
the Steps for creating a Shared Assembly</span></span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
</div>
<div style="font-weight: normal; margin-bottom: 0in;">
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: large;"><span style="font-size: small;">The
.Net Framework E-Book is </span><b>now available for sale</b>.</span></span>
<br />
<br />
<div style="text-align: center;">
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-size: large;"><b>INSTANT
DOWNLOAD AFTER FULL PAYMENT</b></span></span></span></span></div>
</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="hosted_button_id" type="hidden" value="KZ2AKNBPLC7GG" />
<input alt="PayPal – The safer, easier way to pay online." border="0" name="submit" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynowCC_LG.gif" type="image" />
<img alt="" border="0" height="1" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" />
</form>
<br />
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><u><b>Details
of the EBook</b></u></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Name</b>:
.Net Framework - Quick Reference Guide</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Author</b>:
Chandan Sinha</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Format</b>:
PDF</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Language</b>:
English</span></span></span><br />
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><br /></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><u><b>Price</b>:
<b>$2.99 (Exclusively on this website)</b></u></span></span></span><br />
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><u><b><br /></b></u></span></span></span>
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">(<b>Limited Period Offer</b> - Rates slashed from <b>$3.99</b> to <b>$2.99</b>)</span></span></span><br />
<span style="color: red;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Focus Area</b>: Technical Interview in Microsoft .Net</span></span></span></div>
<br />
<h1 class="western">
<a href="https://www.blogger.com/null" name="btAsinTitle"></a>
</h1>
<h1 class="western">
<a href="http://www.amazon.in/gp/product/B00KKD2PPA" target="_blank"><span style="font-family: Arial, sans-serif;">.Net
Framework - Quick Reference Guide </span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">[Kindle
Edition]</span></span></a></h1>
<h1 class="western">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Ebook Link on Amazon Kindle -
<a href="http://www.amazon.in/gp/product/B00KKD2PPA" target="_blank">http://www.amazon.in/gp/product/B00KKD2PPA</a></span></span></h1>
</div>
</div>
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com2tag:blogger.com,1999:blog-2696372599029490903.post-66304742172423365702014-02-24T16:50:00.003+05:302014-02-24T16:52:57.059+05:30ASP.NET Page Life Cycle<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">When
an ASP.NET application is executed, the web page goes through a life
cycle in which it performs a series of processing steps. When a web
page is requested, it is loaded into the Web Server memory, processed
and sent to the web browser. Then it (the object) is unloaded from
the memory. At each of these steps, methods and events are available,
ready to be <i><b>overridden</b></i> according to the need of the
application.</span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
Page class creates a control tree of all the controls on the page.
All the components on the page, except the directives are part of
this control tree.<b> </b></span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>ASP.NET
Page Life Cycle Phases</b></span></span><br />
<ul>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b><i>Initialization</i></b></span></span><br />
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Instantiation
of controls on the web page</b></i></span></span><br />
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Restoration
and Maintenance of state</b></i></span></span><br />
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Execution
of the Event Handler code</b></i></span></span><br />
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Page
Rendering</b></i></span></span><br />
</li>
</ul>
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>ASP.NET
Page Life Cycle Stages</b></span></span><br />
<ul>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Page
Request</b><span style="font-weight: normal;"> – The ASP.NET page
life cycle (PLC) begins after the page is requested </span>by a
user. ASP.NET then determines whether the web page needs to be
parsed and compiled, or a cached version of the page can be sent in
response without running the page.</span></span><br />
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Start</b><span style="font-weight: normal;">
– The </span>page properties such as Request and Response are set
at the Start stage. It is determined whether the request is a
postback (old request) or a new request and <b>IsPostBack</b>
property of the Page is set accordingly. The <b>UICulture</b>
property of the Page is also set at this stage.</span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Events</b></i></span></span><br />
<ul><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>a)
PreInit</b><span style="font-weight: normal;"> – Raised after the
Start stage is complete and before the Initialization stage begins </span></i></span></span>
</ul>
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Initialization</b><span style="font-weight: normal;">
– The controls on the web page are available during </span>page
initialization, and <b>UniqueID</b> property of each control is set.
If applicable, master page and themes are also applied to the page
<span style="font-weight: normal;">during </span>initialization. If
the current request is a postback, the postback data has <b>not</b>
yet been loaded and control property values have <b>not</b> been
restored to the values from view state.</span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Events</b></i></span></span><br />
<ul><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>a)
Init</b><span style="font-weight: normal;"> – </span>Raised after
all controls have been initialized and any skin settings have been
applied. <b>The Init event of individual controls occurs before the
Init event of the page</b>.</i></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i> </i></span></span></ul>
</li>
</ul>
<div style="margin-left: 0.75in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>b)
InitComplete</b><span style="font-weight: normal;"> – Raised at the
end of the page's initialization stage. Only one operation takes
place between the Init and InitComplete events: </span><u><span style="font-weight: normal;">tracking
of view state changes is turned on</span></u><span style="font-weight: normal;">.</span></i></span></span><br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><span style="font-weight: normal;">View
state tracking enables controls to persist any values that are
programmatically added to the ViewState collection. Until view state
tracking is turned on, any values added to view state are lost across
postbacks. Controls typically turn on view state tracking immediately
after they raise their Init event. </span></i></span></span>
</div>
<ul>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Load</b><span style="font-weight: normal;">
– During load, if the current request is a postback, control
properties are loaded with information recovered from view state and
control state.</span></span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Events</b></i></span></span><br />
<ul><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>a)
PreLoad</b><span style="font-weight: normal;"> – Raised after the
page loads view state for itself and all controls, and after it
processes postback data that is included with the Request instance. </span></i></span></span><br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><span style="font-weight: normal;"> </span></i></span></span>
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>b)
Load</b><span style="font-weight: normal;"> – The Page object
calls the OnLoad method on the Page object, and then recursively
does the same for each child control until the page and all
controls are loaded. </span><b>The Load event of individual
controls occurs after the Load event of the page</b><span style="font-weight: normal;">.</span></i></span></span></ul>
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Postback
event handling</b><span style="font-weight: normal;"> – </span>If
the request is a postback, the event handlers of the controls are
called. After that, the Validate method of all validator controls is
called, which sets the IsValid property of individual validator
controls and of the page. (There is an exception to this sequence:
the handler for the event that caused validation is called after
validation.)</span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Events</b></i></span></span><br />
<ul><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>a)
Control Events</b><span style="font-weight: normal;"> – These
events should be used to handle specific control events, such as a
Button control's Click event or a TextBox control's TextChanged
event.</span></i></span></span><br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><span style="font-weight: normal;">In
a postback request, if the page contains validator controls, check
the IsValid property of the Page and of individual validation
controls before performing any processing.</span></i></span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>b)
Load Complete</b><span style="font-weight: normal;"> – Raised at
the end of the event-handling stage.</span></i></span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>c)
PreRender</b><span style="font-weight: normal;"> – Raised after
the Page object has created all controls that are required in order
to render the page, including child controls of composite controls.
To do this, the Page object calls </span><b>EnsureChildControls</b><span style="font-weight: normal;">
for each control and for the page. </span></i></span></span>
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><span style="font-weight: normal;">The
Page object raises the PreRender event on the Page object, and then
recursively does the same for each child control. </span><b>The
PreRender event of individual controls occurs after the PreRender
event of the page</b><span style="font-weight: normal;">.</span></i></span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>d)
PreRender Complete</b><span style="font-weight: normal;"> – Raised
after each data bound control whose DataSourceID property is set
calls its DataBind method.</span></i></span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>e)
SaveStateComplete</b><span style="font-weight: normal;"> - Raised
after view state and control state have been saved for the page and
for all controls. Any changes to the page or controls at this point
affect rendering, but the changes will not be retrieved on the next
postback.</span></i></span></span></ul>
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Rendering</b><span style="font-weight: normal;">
– </span>The view state is saved for the page and all controls
before rendering. During the rendering stage, the page calls the
Render method for each control, providing a text writer that writes
its output to the OutputStream object of the page's Response
property.</span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Events</b></i></span></span><br />
<ul><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>a)
Render</b><span style="font-weight: normal;"> - This is not an
event; instead, at this stage of processing, the Page object calls
this method on each control. All ASP.NET Web server controls have a
Render method that writes out the control's markup to send to the
browser. A user control (an .ascx file) automatically incorporates
rendering, so you do not need to explicitly render the control in
code. </span></i></span></span><br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><span style="font-weight: normal;"> </span></i></span></span>
</ul>
</li>
<li><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Unload
- </b>The Unload event is raised after the page has been fully
rendered, sent to the client, and is ready to be discarded. At this
point, page properties such as Response and Request are unloaded and
cleanup is performed.</span></span><br />
<br />
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Events</b></i></span></span><br />
<ul><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>a)
Unload</b><span style="font-weight: normal;"> - Raised for each
control and then for the page. During the unload stage, the page
and its controls have been rendered, so you cannot make further
changes to the response stream. If you attempt to call a method
such as the Response.Write method, the page will throw an exception</span></i></span></span></ul>
</li>
</ul>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com2tag:blogger.com,1999:blog-2696372599029490903.post-5553939324380299482013-10-11T15:10:00.001+05:302013-10-11T15:10:26.341+05:30ASP.NET HttpHandlers – Are they really required?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">ASP.NET
HttpHandler is a process that runs in response to a request that is
made to an ASP.NET Web application. Almost everything we do in an
HttpHandler, can be done in a normal .aspx page. So, why do we need
HttpHandlers? Are they really required?</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Given
below is the explanation of why HttpHandlers are really required:</span></span></div>
<div style="margin-bottom: 0in;">
</div>
<ol>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Reusability
& Portability – HttpHandlers are more reusable and portable
than normal .aspx pages. Since there are no visual elements in an
HttpHandler, they can be easily placed into their own assembly and
reused from project to project.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">HttpHandlers
are relatively less expensive than the PageHandler. A page goes
through a set of events to be processed at the server (such as
onInit, onLoad, etc.), ViewState and postbacks or simply the
complete Page Life Cycle. When you really have nothing to do with
the complete page life cycle (like displaying images), HttpHandlers
are very useful.</span></span></div>
</li>
</ol>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-90372479101660512962013-10-10T22:48:00.004+05:302013-10-11T14:54:31.288+05:30Handlers in ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">Handler
is an agent of communication or a medium which is responsible for
communication in the absence of the actual user. Technically,
a <i><b>Handler is a class which is responsible for
Instantiation of a class i.e; allocation of memory</b></i>.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">Console
applications or Windows applications do not have handlers. We declare
a class and create an object of that class in the Main() method. We
as a developer are solely responsible for handling the class –
specifically - instantiation of the class.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">However,
Web applications have handlers. In GUI Web Applications we never
create an object of the “_default” page which inherits the Page
class.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">In
Web Services, the Web Service class is never instantiated.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">In
WCF, the Service class, which inherits the IService Interface is
never instantiated.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">Now
comes the question – <b>Who instantiates the above mentioned
classes?</b></span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">Behind
the scene, the Handler is responsible for instantiation of the above
mentioned classes. </span>ASP.NET maps HTTP requests to HTTP handlers
based on the extension of the requested file (type of file). Each
HTTP handler can process individual HTTP URLs or groups of URL
extensions in an application. ASP.NET includes several built-in HTTP
handlers:</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">a) <span style="background: #ffffff;">ASP.NET
– </span><b><span style="background: #ffffff;">System.Web.UI.PageHandlerFactory</span></b></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">b) <span style="background: #ffffff;">Web
Service – </span><b><span style="background: #ffffff;">System.Web.Services.Protocols.WebServiceHandlerFactory</span></b></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">c) <span style="background: #ffffff;">WCF
– </span><b><span style="background: #ffffff;">System.ServiceModel.Activation.ServiceHttpHandlerFactory</span></b></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">There
are different drivers for different protocols. The driver or API of
the protocol (ex – http.sys) has to have the ability to
differentiate and resolve requests.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="background: #ffffff;">
</span></span>
</div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;">.sys
files are the drivers for protocols. <b>http.sys</b> file
is a driver or API or listener for the HTTP protocol. You can say
that HTTP is abstraction, while http.sys is encapsulation. http.sys
file handles the request and response in HTTP. The http.sys file is
located in <b>C:\Windows\System32\drivers\</b> folder.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: #666666;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="background: #ffffff;"><br />When
a request arrives on the server, the drivers for the protocols (.sys
files) handles that request and forwards that request to a particular
handler according to the extensions.</span></span></span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-20170256815453412352013-10-02T08:55:00.004+05:302013-10-03T10:02:17.457+05:30Conversion of Seconds to HH:MM:SS format<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;">Recently I faced a requirement of converting seconds to HH:MM:SS format. After some R&D, I found the following solution:</span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="color: black;"><span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><b>CODE</b></span></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">DECLARE</span><span style="color: black;"> </span><span style="color: teal;">@in_seconds</span><span style="color: black;"> </span><span style="color: blue;">int</span></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">SET</span><span style="color: black;"> </span><span style="color: teal;">@in_seconds</span><span style="color: black;"> </span><span style="color: grey;">=</span><span style="color: black;"> 3661 </span><span style="color: green;">-- One Hour One Minute and One Second</span></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">SELECT</span><span style="color: black;"> </span><b><span style="color: magenta;">CONVERT</span><span style="color: grey;">(</span><span style="color: blue;">CHAR</span><span style="color: grey;">(</span><span style="color: black;">8</span><span style="color: grey;">),</span><span style="color: black;"> </span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: magenta;">SECOND</span><span style="color: grey;">,</span><span style="color: black;"> </span><span style="color: teal;">@in_seconds</span><span style="color: grey;">,</span><span style="color: black;"> 0</span><span style="color: grey;">),</span><span style="color: black;"> 108</span><span style="color: grey;">)</span></b><span style="color: black;"> </span><span style="color: blue;">As </span><span style="color: black;"></span><span style="color: teal;">Hour_Minute_Second</span></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="color: black;"><span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><b>OUTPUT</b></span></span></div>
<div style="color: #666666; line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><span style="color: #666666;"><span style="color: teal;">01:01:01</span></span><br /><span style="color: #666666;"><span style="color: teal;"><br /></span></span><span style="color: #666666;"><b>Note:</b> This SQL code is applicable <u><i>only for time less than 24 hours</i></u>.</span></span></div>
<div style="line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="background-color: white;"><span style="color: #666666;"><span style="font-family: Arial, Helvetica, sans-serif; line-height: 16px;">To overcome this limitation of 24 hours, I created the following function, which has the ability to return correct time duration for large time duration in seconds:</span></span></span></div>
<div style="line-height: 16px; margin-bottom: 0in;">
<span style="background-color: white;"><span style="color: #666666; font-family: Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, Helvetica, sans-serif;">USE [AdventureWorks]</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GO</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">/****** Object: UserDefinedFunction [dbo].[fnc_convert_seconds_to_HHMMSS] Script Date: 10/02/2013 08:48:33 ******/</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">SET ANSI_NULLS ON</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GO</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">SET QUOTED_IDENTIFIER ON</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">GO</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">CREATE FUNCTION [dbo].[fnc_convert_seconds_to_HHMMSS]</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">(</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">@dc_time decimal(18,2)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">RETURNS VARCHAR(20)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">AS</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">BEGIN</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><b>RETURN REPLACE(STR(CONVERT(INT,@dc_time/3600), LEN(LTRIM(CONVERT(INT,@dc_time/3600)))) + ':' + STR(CONVERT(INT,(@dc_time/60)%60), 2) + ':' + STR(@dc_time%60, 2), ' ', '0')</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">END</span><br />
<br />
<b><span style="font-family: Arial, Helvetica, sans-serif;">Example: </span></b><i><span style="font-family: Arial, Helvetica, sans-serif;">SELECT dbo.fnc_convert_seconds_to_HHMMSS(36460) AS vc_time_in_HHMMSS</span></i><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Output: </b><i>10:07:40</i></span><br />
<span style="background-color: white; line-height: 16px;"><span style="color: #666666; font-family: Courier New, monospace;">
</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com1tag:blogger.com,1999:blog-2696372599029490903.post-62806966204221042102013-09-23T21:15:00.000+05:302013-09-24T17:36:21.221+05:30Enumerate the Steps for creating a Shared Assembly<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 1: Generate a Strong Name Key:</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i><b>D:\Project\DLL\sn -k dll.snk</b></i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The above statement will write a Kay pair to dll.snk file</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 2: Associate the Strong Name Key with source code</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 2.1:</b> Create a program to be used as DLL - First.cs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">using System;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">using System.Reflection;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>[assembly:AssemblyKeyFile("dll.snk")]</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">public class Employee</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public string Data()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return "Anuj Ranjan";</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">a) Save the file as First.cs in <u>D:\Project\DLL\First.cs</u></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">b) Compile the program to create a DLL from the Command Prompt as given below:</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><i><b>D:\Project\DLL>csc /t:library First.cs</b></i></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">c) The above statement will create a DLL named <b><u>First.dll</u></b>, with the strong name key in it.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 2.2:</b> Create another program to implement the DLL - Second.cs</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">using System;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">public class Trial</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public static void Main()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Employee e = new Employee();</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Console.WriteLine(e.Data());</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Save the file as Second.cs in <u>D:\Project\Implement\Second.cs</u></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 3: Install the DLL in GAC</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i><b>D:\Project\DLL\GACUTIL -i First.dll</b></i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>GACUTIL</b> is a command which is used to install a strong named dll in the Global Assembly Cache.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 4: Add the reference of the DLL in the program</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i><b>D:\Project\Implement\csc /r:d:\Project\DLL\First.dll Second.cs</b></i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Step 5: Execute the program</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><i><b>D:\Project\Implement\Second</b></i></span></div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-76088922176669981022013-09-07T00:17:00.002+05:302013-09-07T00:18:57.591+05:30Fundamental Windows Communication Foundation Concepts<div dir="ltr" style="text-align: left;" trbidi="on">
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">WCF
programming model consists of a <i>runtime</i> and a set of <i>APIs</i>
and is used for creating systems that communicate (sends and receives
messages) between <i>clients</i> and <i>services</i>.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Messaging
and Endpoints</b></span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
main concept of WCF is <b>Message–Based Communication</b>. In the
programming model anything that can can be modeled as a message (an
HTTP request, a Message Queuing – MSMQ, etc), can be represented in
a uniform way. This concept enables a unified API across contrasting
transport mechanisms.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
<i><b>client</b></i> is an application which initiates a
communication, while a <i><b>service</b></i> is an application which
responds to the client's request. However, the client and the service
may not be necessarily different applications, a <i><b>single</b></i>
application may in fact act both as a client and a service (Duplex
Services and Peer–to– Peer Networking).</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">As
<i><b>Endpoints</b></i> are points or spots for message exchange,
they define all the information required to facilitate message
exchange. A WCF service can expose single or multiple endpoints
(application endpoints or infrastructure endpoints or both). The
client generated endpoint should be compatible with one of the
service's endpoints.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Endpoints
describe the <i><b>address</b></i> (location of the endpoint where
the messages should be send), <i><b>binding</b></i> (how a client can
communicate with the endpoint by sending messages), <i><b>contracts</b></i>
(form of the message) and <i><b>behaviors</b></i> (local
implementation details of the endpoint). This information can be
exposed by the service as metadata, that can be processed to generate
appropriate WCF clients and communication <i>stacks</i>.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Communication
Protocols</b></span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
two elements required in the communication stack is given below:</span></span></div>
<ul>
<li><div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Transport
protocol</b> – Messages can be exchanged over the internet using
common protocols such as <i>HTTP</i> and <i>TCP</i>. Protocols that
support communication with Message Queuing applications and nodes on
a Peer Networking mesh are also included.</span></span></div>
</li>
<li><div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Encoding
mechanisms</b> – Encoding mechanisms specify the format of a
message. Following encoding mechanisms are provided by WCF:</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>a)</b>
<b><i>Text encoding</i></b> – this is an interoperable encoding.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>b)</b>
<b><i>Message Transmission Optimization Mechanism (MTOM) encoding</i></b> – this
is an interoperable way for efficiently sending unstructured binary
data to and from a service.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>c)</b>
<b><i>Binary encoding</i></b> – this is implemented for efficient transfer.</span></span></div>
</li>
</ul>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Note:</b><span style="font-weight: normal;">
E</span>ven more encoding mechanisms (for example, a compression
encoding) can be added using the built-in extension points of WCF.</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Message
Patterns</b></span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Amongst
the several messaging patterns supported by WCF, the most common
Message Exchange Patterns include <i><b>Request–Reply</b></i>,
<i><b>One–Way</b></i>, and <i><b>Duplex</b></i>. The variety of
interactions supported by different protocols depends on the fact
that they support different Message Exchange Patterns (MEX).</span></span></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
messages exchanged in WCF is secure and reliable (a feature of WCF
APIs and runtime).</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com2tag:blogger.com,1999:blog-2696372599029490903.post-18690552516382908222013-09-04T22:44:00.002+05:302013-10-02T08:50:09.663+05:30Conversion of Seconds to Hours:Minutes:Seconds format<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Recently
I faced a requirement of converting seconds to Hours:Minutes:Seconds
format. After some R&D, I found the following solution:</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: black;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>CODE</b></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="color: blue;">DECLARE</span><span style="color: black;">
</span><span style="color: teal;">@in_seconds</span><span style="color: black;">
</span><span style="color: blue;">int</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="color: blue;">SET</span><span style="color: black;">
</span><span style="color: teal;">@in_seconds</span><span style="color: black;">
</span><span style="color: grey;">=</span><span style="color: black;"> 3661 </span><span style="color: green;">--
One Hour One Minute and One Second</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="color: blue;">SELECT</span><span style="color: black;">
</span><b><span style="color: magenta;">CONVERT</span><span style="color: grey;">(</span><span style="color: blue;">CHAR</span><span style="color: grey;">(</span><span style="color: black;">8</span><span style="color: grey;">),</span><span style="color: black;">
</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: magenta;">SECOND</span><span style="color: grey;">,</span><span style="color: black;">
</span><span style="color: teal;">@in_seconds</span><span style="color: grey;">,</span><span style="color: black;">
0</span><span style="color: grey;">),</span><span style="color: black;"> 108</span><span style="color: grey;">)</span></b><span style="color: black;">
</span><span style="color: blue;">As</span><span style="color: black;">
</span><span style="color: teal;">Hour_Minute_Second</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: black;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>OUTPUT</b></span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="color: teal;">01:01:01</span></span></span><br />
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="color: teal;"><br /></span></span></span>
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><b>Note</b>: This SQL code is applicable <u><i>only for time less than 24 hours</i></u>.</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com1tag:blogger.com,1999:blog-2696372599029490903.post-61731572737524549882013-09-02T11:10:00.003+05:302013-09-02T11:13:58.466+05:30Message Patterns in WCF Services<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="text-align: justify;">
<div class="MsoNormal">
<div class="MsoNormal">
<span style="font-family: Arial, sans-serif; font-size: 10pt; line-height: 115%;">Client applications and WCF
services communicate by passing XML messages. Message Exchange Patterns illustrate
how clients and services communicate by passing messages. There are three
message exchange patterns supported by WCF:</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Request
– Reply</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> Message Exchange Pattern<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">One –
Way</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">
Message Exchange Pattern (also called Datagram)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Duplex</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> Message
Exchange Pattern (also called Callback)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast">
<br /></div>
<div class="MsoNormal">
<h4>
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Request
– Reply Message Exchange Pattern</span></b></h4>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">After sending message to a WCF
service, a client application <b>waits for
the reply</b> in <b>Request – Reply</b> pattern.
This is the default and classic pattern for both WCF and Web Services. Since
the client has asked a question, and it expects an answer, it waits for the
service to send a message back containing the answer.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The Request – Reply message
exchange pattern is used when a client requests a service to perform an action,
and it needs some confirmation. Fault exception is handled in Request – Reply
pattern. The Request – Reply pattern is the most used message exchange pattern.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">In Request – Reply Message
Exchange Pattern, only the client can initiate a communication with the service.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<h4>
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">One
– Way Message Exchange Pattern</span></b></h4>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The <b>One – Way</b> Message Exchange Pattern is also known as <b><i>Datagram</i></b>
or <b><i>Fire
and Forget</i></b>. This pattern is used when a client requests the service to take
an action but it does not need any confirmation. Thus neither the service sends
a reply message not the client waits for a reply. A client sends a message (request)
to a WCF service but the service does not send a reply message to the client.
The client <b>does not wait for the reply</b>
and proceeds with other processing work. Some scenario’s for one-way pattern
includes logging in and out, maintenance tasks, heads down data entry and other
repetitive tasks etc.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">An implication of using one –
way pattern is that even if a method call fails due to an exception or invalid
data, the service does not notify the client. If the client needs to be
notified about the failure of the service request, then this pattern should not
be used. This pattern should be used when the client does not need to wait for
a reply from the WCF service.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">In One – Way Message
Exchange Pattern, only the client can initiate a communication with the service.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<h4>
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Duplex
Message Exchange Pattern</span></b></h4>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The <b>Duplex</b> Message Exchange Pattern is also known as <b><i>Callback</i></b>.
Both the client and the service can initiate a communication in the duplex
pattern. It can be used for transactions. The client calls the service, which after
processing the request, callbacks the client with the reply. In the meanwhile, instead
for waiting for the reply (as in Request – Reply pattern), the client proceeds
with other tasks.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">This pattern should be used
when the client (after the client has called the service) expects a
notification or alert from the WCF service.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Note:</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> <i>The <b>One
– Way</b> and <b>Duplex</b> patterns
provides opportunities to fine-tune the performance of applications and to add
more flexibility regarding what happens after a client calls a service.<o:p></o:p></i></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The
presence of <b>One – Way</b> and <b>Duplex</b> patterns in WCF is a <b>major advantage of WCF over Web Services</b>.<o:p></o:p></span></i></div>
<br />
<div class="MsoNormal">
<br /></div>
</div>
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-17141986571940925872013-08-14T15:22:00.000+05:302013-08-14T15:22:11.514+05:30Polymorphism in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-weight: normal;"><i><b>Polymorphism</b></i>
is the ability of an object oriented language (C# in this context) to
</span>allow a base class to define a set of members (formally termed
the <i>polymorphic interface</i>) that are available to all
descendents. A class’s polymorphic interface is constructed using
any number of <i>virtual </i>or <i>abstract </i>members.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
<i><b>virtual</b></i><i> member </i>is a member in a base class that
defines a default implementation that may be changed (<i>overridden</i>)
by a derived class.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">In
contrast, an <i><b>abstract</b></i><i> method </i>is a member in a
base class that <i>does not</i> provide a default implementation, but
<i>does</i> provide a signature. When a class derives from a base
class defining an abstract method, it <i>must </i>be overridden by a
derived type.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">In
either case (virtual or abstract), when derived types override the
members defined by a base class, they are essentially redefining how
they respond to the same request.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Method
Overriding</b><span style="font-weight: normal;"> – Method
Overriding is a process in which a derived class can define its own
version of a method, which was originally defined by its base class.</span></span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Virtual
Keyword</b><span style="font-weight: normal;"> – The </span><i><b>virtual</b></i><span style="font-weight: normal;">
keyword indicates that the base class wants to define a method which
</span><i><span style="font-weight: normal;">may be</span></i><span style="font-weight: normal;">
(but does not have to be) </span><span style="font-style: normal;"><span style="font-weight: normal;">overridden</span></span><span style="font-weight: normal;">
by a derived class. A virtual method provides a default
implementation </span>that all derived types automatically inherit.
If a child class so chooses, it <i>may </i>override the method but
does not <i>have </i>to.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Note</b>:
Subclasses are <i>never required </i>to override virtual methods.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Override
Keyword</b> – The <i><b>override</b></i> keyword is used by a
derived class to to change the implementation details of a virtual
method (defined in the base class). Each overridden method is free to
leverage the default behavior of the parent class using the <i><b>base</b></i><i><span style="font-weight: normal;">
</span></i><span style="font-style: normal;"><span style="font-weight: normal;">keyword.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-style: normal;"><b>Sealed
Keyword</b></span><span style="font-style: normal;"><span style="font-weight: normal;">
– The </span></span><i><b>sealed</b></i><span style="font-style: normal;"><span style="font-weight: normal;">
keyword is basically applied to classes to prevent other types from
extending its behavior via inheritance.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-style: normal;"><span style="font-weight: normal;">It
can also be applied to virtual methods to prevent derived types from
overriding those methods. Ex.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-style: normal;"><span style="font-weight: normal;">public
</span></span><span style="font-style: normal;"><b>override</b></span><span style="font-style: normal;"><span style="font-weight: normal;">
</span></span><span style="font-style: normal;"><b>sealed</b></span><span style="font-style: normal;"><span style="font-weight: normal;">
void GiveBonus(float amount)</span></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">...</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">}</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Any
effort to override the above sealed method in the derived class will
generate compile time error.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Abstract
Classes</b><span style="font-weight: normal;"> – The </span><i><b>abstract</b></i><span style="font-weight: normal;">
keyword can be used in the class definition to prevent direct
creation of an instance of the class. Although abstract classes
cannot be created </span><i><span style="font-weight: normal;">directly</span></i><span style="font-weight: normal;">,
</span>it is still assembled in memory when derived classes are
created. Thus, it is perfectly fine for abstract classes to define
any number of constructors that are called <i>indirectly </i>when
derived classes are allocated.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">An
abstract class can define any number of <i>abstract members</i><span style="font-style: normal;">
(members that does </span><span style="font-style: normal;">not </span><span style="font-style: normal;">supply
a default implementation, but </span><i><b>must</b></i><span style="font-style: normal;">
</span><span style="font-style: normal;">be accounted for by each
derived class).</span></span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
polymorphic interface of an abstract base class simply refers to its
set of virtual and abstract methods. Methods marked with abstract are
pure protocol. They simply define the name, return type (if any), and
parameter set (if required).</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">If
you do not override an abstract method (of the base abstract class)
in the derived class, the derived class will also be considered
abstract, and would have to be marked abstract with the abstract
keyword.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Although
it is not possible to <i>directly </i>create an instance of an
abstract base class, you can freely store references to any subclass
with an abstract base variable.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Q</b><span style="font-weight: normal;">:
</span><b>What is an efficient way to force each child class to
override a virtual method?</b></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>A</b><span style="font-weight: normal;">:
To force each child class to override a virtual method, we can better
define an abstract method (which by </span>definition means you
provide no default implementation whatsoever), in an abstract class.</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-49717562688983487152013-08-14T15:15:00.000+05:302013-08-14T15:15:30.210+05:30Inheritance in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Inheritance</b></i>
is the ability of an object oriented language (C# in this context) to
build new class definitions based on existing class definitions.
Inheritance allows us to extend the behavior of a base (<i>parent</i>)
class by inheriting core functionality into the derived subclass
(<i>child class</i>). Inheritance promotes code re-usability.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Inheritance
preserves encapsulation – private members of the base class can
never be accessed from an object reference of the derived class.
Private members can <i>only </i>be accessed by the class that defines
it.</span></span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">C#
does not support Multiple Inheritance. A class in C# cannot directly
derive from two or more base classes.</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-26926985697156893872013-08-14T15:12:00.001+05:302013-08-14T15:12:43.941+05:30What is Black Box programming?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-style: normal;"><span style="font-weight: normal;">A</span></span>
well-encapsulated class should protect its data and hide the details
of how it operates from the outside world. This is often termed <i><b>Black Box programming</b></i>.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The beauty of this approach is that an
object is free to change how a given method is implemented under the
hood. It does this without breaking any existing code making use of
it, provided that the parameters and return values of the method
remain constant.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The notion of Black Box programming is very closely related to the concept of Encapsulation. </span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-22199406920375162762013-08-14T15:08:00.002+05:302013-08-14T15:22:50.507+05:30Encapsulation in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Encapsulation</b></i>
is the ability of an object oriented language (C# in this context) to
hide unnecessary implementation details from the object user.
Encapsulation makes coding simpler and helps to preserve data
integrity.</span></span>
<br />
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">According
to the concept of encapsulation, an object’s internal data should
not be directly accessible from an object instance. Members of a
class that represent an object’s state should not be marked as
public. The state of an object should only be altered indirectly by
using public members. C# prefers properties to encapsulate data. Ex.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">class
ABC</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: green;"><span style="font-family: Courier New, monospace;"><span style="font-size: small;">//
private data members</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">private
int roll;</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">private
int class;</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">private
string name;</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: green;"><span style="font-family: Courier New, monospace;"><span style="font-size: small;">//
public properties</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">public
int Roll</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">get
{ return roll; }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">set
{ roll = value; }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">}</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">public
int Class</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">get
{ return class; }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">set
{ class = value; }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">}</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">public
string Name</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">get
{ return name; }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">set
{ name = value; }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">}</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: green;"><span style="font-family: Courier New, monospace;"><span style="font-size: small;">//
constructor</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">public
ABC()</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div style="margin-bottom: 0in;">
<span style="color: green;"><span style="font-family: Courier New, monospace;"><span style="font-size: small;">//
values are assigned to data members via properties</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Roll
= 10;</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Class
= 9;</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Name
= “Rajveer Raj Banti”;</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">}</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">}</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-72935055811516972752013-08-08T11:47:00.001+05:302013-08-09T09:45:41.629+05:30Evolution of C# (1.0 – 5.0)<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">C# is a
multi-paradigm (structured, imperative, object-oriented,
event-driven, functional, generic, reflective, concurrent)
programming language. It was developed within Microsoft. The
development team which consisted of <b>Scott Wiltamuth</b>, <b>Peter
Golde</b> and others was led by <b>Anders Hejlsberg</b>. </span>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">The
first version of C# was released by Microsoft in July 2000. The
latest version of C# is 5.0, which was released on August 15, 2012.</span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>C#
1.0</b></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">C#
1.0 was released by Microsoft with <b>Visual Studio 2002</b>. C# 1.0
targets <b>.NET Framework 1.0</b>. It was the first language
adopted by developers to build .NET applications.</span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>C#
1.2</b></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">C#
1.2 was released by Microsoft with <b>Visual Studio 2003</b>. C# 1.2
targets <b>.NET Framework 1.1</b>.</span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>C#
2.0</b></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">C#
2.0 was released by Microsoft with </span><b>Visual Studio 2005</b><span style="font-weight: normal;">.
C# 2.0 targets </span><b>.NET Framework 2.0</b><span style="font-weight: normal;">.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">The
new features added in C# 2.0 are as given below:</span></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">Generics</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Partial
types</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Anonymous
methods</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Iterators</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Nullable
types</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Private
setters (properties)</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Method
group conversions (delegates) </span>
</div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Covariance
and Contravariance</span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>C#
3.0</b></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">C#
3.0 was released by Microsoft with </span><b>Visual Studio 2008</b><span style="font-weight: normal;">.
It is also compatible with </span><b>Visual Studio 2010</b><span style="font-weight: normal;">.
C# 3.0 targets the </span><b>.NET Framework 2.0 (Except LINQ/Query
Extensions)</b><span style="font-weight: normal;">, </span><b>.NET
Framework 3.0 (Except LINQ/Query Extensions)</b><span style="font-weight: normal;">
and </span><b>.NET Framework 3.5</b><span style="font-weight: normal;">.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">The
new features added in C# 3.0 are as given below:</span></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">Implicitly
typed local variables (var)</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Object
and collection initializers</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Auto-Implemented
properties</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Anonymous
types</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Extension
methods</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Query
expressions</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Lambda
expressions</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Expression
trees</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Partial
Methods </span>
</div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">LINQ</span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>C#
4.0</b></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">C#
4.0 was released by Microsoft with </span><b>Visual Studio 2010</b><span style="font-weight: normal;">.
C# 4.0 targets </span><b>.NET Framework 4.0</b><span style="font-weight: normal;">.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">The
new features added in C# 4.0 are as given below:</span></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">Dynamic
binding (Late binding)</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Named
and optional arguments</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Generic
Covariance and Contravariance</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Embedded
interop types ("NoPIA") </span>
</div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>C#
5.0</b></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">C#
5.0 was released by Microsoft with </span><b>Visual Studio 2012</b><span style="font-weight: normal;">.
C# 5.0 targets </span><b>.NET Framework 4.5</b><span style="font-weight: normal;">.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">The
new features added in C# 4.0 are as given below:</span></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">Asynchronous
methods</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Caller
info attributes</span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>Future</b></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">The
upcoming versions of C# might include the following features:</span></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-weight: normal;">Compiler-as-a-service
("Roslyn")</span></span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>The
Evolution of C# programming language</b></span></div>
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="360" scrolling="no" src="http://channel9.msdn.com/Events/Students-to-Business-Day-Belgium/Students-to-Business-Day-Belgium-2011/The-Evolution-of-the-C-Programming-Language/player?w=484&h=348" width="490"></iframe></div>
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-67177498204826614042013-08-07T17:46:00.001+05:302013-08-07T17:46:51.521+05:30Casting and Reference Conversions – Differentiate between Upcasting and Downcasting<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">An
object reference can be:</span></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Implicitly
<i><b>upcast</b></i> to a base class reference</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Explicitly
<i><b>downcast</b></i> to a subclass reference</span></span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Upcasting
and downcasting between compatible reference types performs <i>reference
conversions</i>: a new reference is (logically) created that points
to the same object. </span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>An upcast always succeeds; a downcast succeeds
only if the object is suitably typed</b></i>.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Upcasting</b></span></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-weight: normal;">An
</span>upcast operation creates a base class reference from a
subclass reference. For example:</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Vechicle
oVechicle = new Vechicle();</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><b>Car
oCar = oVechicle; // Upcast</b></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">After
the upcast, variable <span style="font-family: Courier New, monospace;"><b>oCar</b></span>
still references the same <span style="font-family: Courier New, monospace;">Vechicle</span>
object as variable <span style="font-family: Courier New, monospace;">oVechicle</span>.
The object being referenced is not itself altered or converted:</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Console.WriteLine
(<span style="font-weight: normal;">oCar</span><span style="font-weight: normal;">
== oVechicle</span>); // True</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Although
<span style="font-family: Courier New, monospace;"><span style="font-weight: normal;">oCar</span></span>
and <span style="font-family: Courier New, monospace;"><span style="font-weight: normal;">oVechicle</span></span>
refer to the identical object, <span style="font-family: Courier New, monospace;"><span style="font-weight: normal;">oCar</span></span>
has a more restrictive view on that object:</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Console.WriteLine
(<span style="font-weight: normal;">oCar</span>.Name); // OK</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Console.WriteLine
(<span style="font-weight: normal;">oCar</span>.VechicleCount); //
Error: VechicleCount undefined</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
last line generates a compile-time error because the variable <span style="font-family: Courier New, monospace;"><span style="font-weight: normal;">oCar</span></span>
is of type <span style="font-family: Courier New, monospace;"><span style="font-weight: normal;">Car</span></span>,
even though it refers to an object of type <span style="font-family: Courier New, monospace;">Vechicle</span>.
To get to its <span style="font-family: Courier New, monospace;">VechicleCount</span>
field, you must <i><b>downcast</b></i><i> </i>the <span style="font-family: Courier New, monospace;">Vechicle</span>
to a <span style="font-family: Courier New, monospace;"><span style="font-weight: normal;">Car</span></span>.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Downcasting</b></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
downcast operation creates a subclass reference from a base class
reference. For example:</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Vechicle
oVechicle = new Vechicle();</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Car
oCar = oVechicle; <b>// Upcast</b></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Vechicle
oVechicle1 = (Vechicle)oCar; <b>// Downcast</b></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Console.WriteLine
(oVechicle1.VechicleCount); // <No error></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Console.WriteLine
(oVechicle1 == oCar); // True</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Console.WriteLine
(oVechicle1 == oVechicle); // True</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">As
with an upcast, only references are affected—not the underlying
object. A downcast requires an explicit cast because it can
potentially fail at runtime:</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Maruti
oMaruti = new Maruti();</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Car
oCar = oMaruti; // Upcast always succeeds</span></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">Vechicle
oVechicle = (Vechicle)oCar; // Downcast fails: oCar is not a Car</span></span></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">If
a downcast fails, an <i><b>InvalidCastException</b></i> is thrown.
This is an example of <i>runtime type checking</i><i>.</i></span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-23465340839845009072013-08-07T12:24:00.003+05:302013-08-07T12:24:52.693+05:30Explain the IEnumerable Interface<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Namespace</b>
– System.Collections</span></span></div>
<div style="margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Assembly</span></span></b><b><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-weight: normal;">
– </span></span></span></b><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">
mscorlib (in mscorlib.dll)</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>IEnumerable</b>
Interface is the base interface for all <b>non-generic collections</b>
that can be enumerated. It exposes an enumerator, which supports a
simple iteration over a non-generic collection.
<b>System.Collections.Generic.IEnumerable<T></b> is the generic
version of this interface.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">IEnumerable
contains a single method, <b>GetEnumerator</b>, which returns an
IEnumerator which provides the ability to iterate through the
collection by exposing a <b>Current</b> property and <b>MoveNext</b>
and <b>Reset</b> methods.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Implementation
of <b>IEnumerable</b> and <b>IEnumerator</b> on collection classes
enables the foreach syntax on a collection. The members of these
interfaces are not explicitly called, but they are implemented to
support the use of foreach to iterate through the collection.</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-73804881916275599952013-08-05T19:56:00.001+05:302013-08-05T19:58:17.472+05:30Static Constructors - What is the output of the C# code?<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">class</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">public</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> A(</span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">string</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> text)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">Console</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">.WriteLine(text);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">class</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">B</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">static</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> a1 = </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">new</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">(</span><span style="background: white; color: #a31515; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">"a1"</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> a2 = </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">new</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">(</span><span style="background: white; color: #a31515; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">"a2"</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">static</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> B()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> a1 = </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">new</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">(</span><span style="background: white; color: #a31515; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">"a3"</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">public</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> B()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> a2 = </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">new</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">A</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">(</span><span style="background: white; color: #a31515; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">"a4"</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">class</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">Program</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">static</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">void</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> Main(</span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">string</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">[] args)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">B</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> b = </span><span style="background: white; color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">new</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="background: white; color: #2b91af; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: white;">B</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;"> }<o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Courier New'; font-size: 10pt;">}</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, Helvetica, sans-serif; font-size: 10pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">Before any code of the type B gets executed,
its static constructor will be invoked first. It initializes static data fields
and then executes statements inside the static constructor. Therefore, it
prints a line of “<b>a1</b>”, and then
another line of “<b>a3</b>”.<o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">When
the execution flow reaches the statement B b = new B(), the ordinary
constructor is invoked. It initializes its data fields first and then the
statements in its constructor method, so it prints a line of “<b>a2</b>”, and then another line of “<b>a4</b>”.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">a1<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">a3<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">a2</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 10.0pt;">a4</span><span style="font-size: 10.0pt;"><o:p></o:p></span></div>
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-19646035542168961102013-08-03T04:01:00.001+05:302013-08-05T15:32:07.524+05:30Access Modifiers in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Access
Modifiers are used to control the visibility of a type (classes,
interfaces, structures, enumerations, and delegates) or their members
(properties, methods, constructors, and fields) to other parts of an
application.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Role
of each access modifier and where it may be applied:</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<table border="1" cellpadding="4" cellspacing="0" style="height: 453px; width: 613px;">
<colgroup><col width="57*"></col>
<col width="57*"></col>
<col width="142*"></col>
</colgroup><tbody>
<tr valign="TOP">
<th bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Access Modifier</span></span></span></th>
<th bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Applicable to</span></span></span></th>
<th bgcolor="#800080" width="56%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Description</span></span></span></th>
</tr>
<tr valign="TOP">
<td bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>public</b></span></span></span></td>
<td width="22%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Types or type
members</span></span></td>
<td width="56%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Public items have
no access restrictions. A public member can be accessed from an
object, as well as any derived class. It can also be accessed from
other external assemblies.</span></span></td>
</tr>
<tr valign="TOP">
<td bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>private</b></span></span></span></td>
<td width="22%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Type members or
<b>nested</b> types</span></span></td>
<td width="56%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Private items can
only be accessed by the class (or structure) that defines the
item.</span></span></td>
</tr>
<tr valign="TOP">
<td bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>protected</b></span></span></span></td>
<td width="22%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Type members or
<b>nested</b> types</span></span></td>
<td width="56%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Protected items can
be used by the class which defines it, and any child class.
However, protected items cannot be accessed from the outside world
using the C# dot operator.</span></span></td>
</tr>
<tr valign="TOP">
<td bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>internal</b></span></span></span></td>
<td width="22%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Type or type
members</span></span></td>
<td width="56%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Internal items are
accessible only within the current assembly. Therefore, if you
define a set of internal types within a .NET class library, other
assemblies are not able to make use of them.</span></span></td>
</tr>
<tr valign="TOP">
<td bgcolor="#800080" width="22%"><span style="color: white;"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>protected
internal</b></span></span></span></td>
<td width="22%"><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Type members or
<b>nested</b> types</span></span></td>
<td width="56%"><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">When
the protected and internal keywords
are combined on an item, the item is accessible within the
defining assembly, the defining class, and by derived classes.</span></span></div>
</td>
</tr>
</tbody></table>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Note</b>:
<span style="font-weight: normal;">By default, type members (ex. members of a class) are
</span><i><b>implicitly private</b></i><i><span style="font-weight: normal;">
</span></i><span style="font-weight: normal;">while types (ex. classes) are
</span><i><b>implicitly internal</b></i><span style="font-weight: normal;">.</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #00ae00;"><span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;">//
An <b>internal</b> class with a <b>private</b> default constructor.</span></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;">class
Country</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;">{</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;"> </span><span style="color: #00ae00;"><span style="font-weight: normal;">//
default constructor – implicitly <b>private</b></span></span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;"> Country()</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;"> {</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;"> }</span></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;">}</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Note</b><span style="font-weight: normal;">:
Nested types can have private access, but non-nested types cannot be
marked private.</span></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;">public
class Country</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"> <span style="color: #00ae00;">//
OK! Nested types can be marked private.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><b> private</b>
enum FlagColor</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"> {</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"> Red,
Green, Blue</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"> }</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: TheSansMonoConNormal, sans-serif;"><span style="font-size: x-small;">}</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><span style="font-weight: normal;">Here,
it is permissible to apply the </span><span style="font-weight: normal;">private
</span><span style="font-weight: normal;">access modifier on the
nested type. However, non-nested </span>types (such as the <span style="font-family: Courier New, monospace;">Country</span>)
can only be defined with the <span style="font-family: Courier New, monospace;">public</span>
or <span style="font-family: Courier New, monospace;">internal</span> modifiers.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: #00ae00;"><span style="font-family: Courier New, monospace;"><span style="font-size: small;"><span style="font-weight: normal;">//
Error! Nonnested types cannot be marked private!</span></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><b>private</b>
class Country</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">{}</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-13259189939150935782013-08-02T03:33:00.002+05:302013-08-02T03:34:38.453+05:30static keyword in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">When
a class member is prefixed by a <i>static</i> keyword, it becomes a
<i>static member</i>, and it must be invoked directly from the class
level, rather than from an object reference variable. Static members
promote a given item to the class level rather than the object level.
Static data is allocated once and shared among all instances of the
class. The CLR allocates the static data into memory exactly one
time.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">While
any class can define static members, they are quite commonly found
within <b>utility classes</b>. By definition, a utility class is a
class that only exposes static functionality. It does not maintain
any object-level state and is not created with the new keyword.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Rather,
a utility class exposes all functionality as class-level (a.k.a.,
static) members.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
<i>static</i> keyword can be applied to <b>data members</b>, <b>methods</b>,
<b>properties</b>, <b>constructor</b>, and <b>entire class
definition</b>.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Note</b>:
<i>this</i> keyword cannot be used with a static member because <i>this</i>
implies an object. A static member cannot reference non-static
members in its implementation (it will generate a compiler error).</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Q</b>:
What will happen if you attempt to assign the value of a static data
member in a typical (non-static or instance level) constructor?</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>A</b>:
The the value of the static data member will be <b>reset</b> each
time you create a new object.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Static
Constructor</b>: A static constructor is a special constructor that
is an ideal place to initialize the values of static data when the
value is not known at compile time (e.g., read in the value from an
external file, a database, generate a random number, etc).</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
static constructor allows us to initialize static members of a class
at runtime. The CLR calls all static constructors before first use
(and never calls them again for that instance of the application).</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Few
interesting points regarding static constructors</b>:</span></span></div>
<ol>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
given class can define <b>only one</b> static constructor. The
static constructor cannot be overloaded.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
static constructor does not take an access modifier and cannot take
any parameters.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
static constructor executes exactly one time, regardless of how many
objects of the type are created.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
runtime invokes the static constructor when it creates an instance
of the class or before accessing the first static member invoked by
the caller.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
static constructor cannot be called directly through the code.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
static constructor executes before any instance-level constructors.</span></span></div>
</li>
</ol>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Static
Class</b>: A static class cannot be created using the <i>new</i>
keyword (i.e; it cannot have an instance or object). It can contain
only static members (static <span style="font-weight: normal;">data
members, static methods, static properties or a static constructor</span>).</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-9072197499106899212013-08-02T01:05:00.000+05:302013-09-10T21:05:03.744+05:30Endpoint in a WCF Service<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
WCF service </span></span><span style="font-family: Arial, sans-serif;">exposes
its contract via collection of Endpoints (one or more endpoints)<span style="font-size: small;">. An endpoint in WCF is
an entity which facilitates access of a client to a WCF service. All
communication with the WCF service occurs through the endpoints
exposed by the service.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">In
simple terms, it's an URL on which clients can communicate to the
service.</span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">An
endpoint consists of the following four properties:</span></span></div>
<ol>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Address</b>
– The Endpoint's Address is a network address where the Endpoint
resides. It indicates the location of the endpoint, i.e.; where it
can be found. The address uniquely identifies the endpoint.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
address of an endpoint is represented in the WCF object model by the
</span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>EndpointAddress</b></i></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">
class.</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">An
</span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i>EndpointAddress</i></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">
class contains:</span></span></div>
<ol type="a">
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
</span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>URI</b></i></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">
property which represents the address of the endpoint.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">An
</span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Identity</b></i></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">
property, which represents the security identity of the service and
a collection of optional message headers. The optional message
headers are used to provide additional and more detailed addressing
information to identify or interact with the endpoint.</span></span></div>
</li>
</ol>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Binding</b></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">
– The binding specifies how a client can communicate with the
endpoint and includes:</span></span></div>
<ol type="a">
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Transport
protocol (ex – TCT or HTTP).</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Message
encoding (text or binary).</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">Security
requirements (SSL or SOAP message security).</span></span></div>
</li>
</ol>
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">A
binding is represented in the WCF object model by the abstract base
class </span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Binding</b></i></span></span><span style="font-family: Arial, sans-serif;"><span style="font-size: small;">. </span></span>
</li>
</ol>
<ol start="3">
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Contracts</b>
– The contract outlines the functionality exposed by the endpoint
to the client. It specifies:</span></span></div>
<ol type="a">
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
operations available for the client.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
form of the message.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
type of input parameters or data required to call the operation.</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
expected type of processing or response message for the client.</span></span></div>
</li>
</ol>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Behaviors</b>
– The endpoint has a set of behaviors that specify local
implementation details of the endpoint. The local behavior of the
service endpoint can be customized by using endpoint behaviors
(which achieves this by participating in the process of building a
WCF runtime).</span></span></div>
</li>
</ol>
<br />
<h3 style="text-align: center;">
Endpoint in a WCF Service - Explained by Mr. Sandeep Karan</h3>
<br />
<div>
<iframe allowfullscreen="" frameborder="0" height="490" src="//www.youtube.com/embed/Ka4afgwmMrc?rel=0" width="640"></iframe>
<div>
<br />
<h3 style="text-align: center;">
Endpoint in a WCF Service</h3>
<br />
<div>
<iframe allowfullscreen="" frameborder="0" height="490" src="//www.youtube.com/embed/GC344FZeWqc?rel=0" width="640"></iframe>
<div>
</div>
</div>
</div>
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-17379189164397377672013-07-31T23:41:00.004+05:302013-07-31T23:41:51.083+05:30Ranking functions in SQL<div dir="ltr" style="text-align: left;" trbidi="on">
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i>Ranking
functions</i> introduced with SQL Server 2005 allow us to assign a
number to each row returned from a query. They allow us to rank each
row in respect to others in several different ways. Ranking functions
can be used <b>only</b> with the SELECT and ORDER BY statements. They
cannot be used directly in a WHERE or GROUP BY clause, but can be
used in a CTE or derived table.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br />
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
syntax for ranking functions is shown as follows:</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br />
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><b><function_name>()
OVER([PARTITION BY <partition_by_list>]</b></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><b>ORDER
BY <order_by_list>)</b></span></span></div>
<ul>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>function_name</b>:
Can be one of <i><b>ROW_NUMBER</b></i>, <i><b>RANK</b></i>,
<i><b>DENSE_RANK</b></i>, and <i><b>NTILE</b></i></span></span></div>
</li>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>OVER</b>:
Defines the details of how the ranking should order or split the
data</span></span></div>
</li>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>PARTITION
BY</b>: Details which data the column should use as the basis of the
splits</span></span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>ORDER
BY</b>: Details the ordering of the data</span></span></div>
</li>
</ul>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">There
are four ranking functions in SQL Server:</span></span>
</div>
<ol>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>ROW_NUMBER</b>
– It allows us to provide incrementing sequential integer values
to the rows in the result-set of a query based on logical order that
is specified in the <i>ORDER BY </i>subclause of the <i>OVER </i>clause.
The <i>ROW_NUMBER</i> function contains the <i><b>OVER</b></i>
clause, which the function uses to determine the numbering behavior.
The <i><b>ORDER BY</b></i><b> </b>option, which determines the order
in which the function applies the numbers, must be included in the
query. We have the option of starting the numbers over whenever the
values of a specified column change, called <i><b>partitioning</b></i>,
with the <i><b>PARTITION BY</b></i> clause.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Example
Query 1</b>: Basic use of ROW_NUMBER()</i></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">SELECT
CustomerID, FirstName + ' ' + LastName AS Name,</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i><b>ROW_NUMBER()
OVER (ORDER BY LastName, FirstName) AS Row</b></i></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
Sales.Customer AS c</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">INNER
JOIN Person.Person AS p ON c.PersonID = p.BusinessEntityID;</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Example
Query 2</b><span style="font-weight: normal;">: Using ROW_NUMBER() in
a </span><b>CTE</b></i></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">WITH
<b>customers</b> AS(</span></span></div>
<ol><div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">SELECT
CustomerID, FirstName + ' ' + LastName AS Name,</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i><b>ROW_NUMBER()
OVER (ORDER BY LastName, FirstName) AS Row</b></i></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
Sales.Customer AS c</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">INNER
JOIN Person.Person AS p ON c.PersonID = p.BusinessEntityID</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">)</span></span></div>
</ol>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">SELECT
CustomerID, Name, Row</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
<b>customers</b></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">WHERE
Row > 50</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">ORDER
BY Row;</span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Example
Query 3</b><span style="font-weight: normal;">: Using </span><b>PARTITION
BY</b><span style="font-weight: normal;"> option in ROW_NUMBER()</span></i></span></span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i>SELECT
CustomerID, FirstName + ' ' + LastName AS Name, c.TerritoryID,</i></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i>ROW_NUMBER()
OVER (</i><i><b>PARTITION BY</b></i><i> c.TerritoryID ORDER BY
LastName</i>, FirstName) AS Row</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
Sales.Customer AS c</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">INNER
JOIN Person.Person AS p ON c.PersonID = p.BusinessEntityID;</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
</li>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>RANK</b>
– <i>RANK</i> assigns the same number to the duplicate rows and
skips numbers not used. It assigns an ascending, nonunique ranking
number to a set of rows, giving the same number to duplicate rows;
numbers are skipped for the number of rows that have the same value.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>If
rows 2 and 3 are duplicates, RANK will supply the values 1, 3, 3,
and 4.</b></i></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Example
Query 1</b><span style="font-weight: normal;">: Using </span><b>RANK</b></i></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">SELECT
ROW_NUMBER() OVER (PARTITION BY SUBSTRING(LastName,1,2) ORDER BY
LastName) AS RowNum,</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i><b>RANK()
OVER(ORDER BY SUBSTRING(LastName,1,2) ) AS Ranking</b></i>,
CONCAT(FirstName,' ',LastName) AS CustomerName, UnclearedBalance</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
CustomerDetails.Customers</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">WHERE
UnclearedBalance is not null</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">ORDER
BY Ranking</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
</li>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>DENSE_RANK</b>
- This is similar to <i>RANK</i>, but each row number returned will
be one greater than the previous setting, no matter how many rows
are the same. <i>DENSE_RANK</i> doesn’t skip numbers.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>If
rows 2 and 3 are duplicates, DENSE_RANK will supply the values 1, 2,
2, and 3.</b></i></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Example
Query</b><span style="font-weight: normal;">: </span></i></span></span>
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i><span style="font-weight: normal;">SELECT
ROW_NUMBER() OVER (PARTITION BY SUBSTRING(LastName,1,2) </span></i>ORDER
BY LastName) AS RowNum,</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;"><i><b>DENSE_RANK()
OVER(ORDER BY SUBSTRING(LastName,1,2) ) AS Ranking</b></i>,
CONCAT(FirstName,'',LastName) AS CustomerName, UnclearedBalance</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
CustomerDetails.Customers</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">WHERE
UnclearedBalance is not null</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">ORDER
BY Ranking</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>Note</b>:
Both <i>RANK</i> and <i>DENSE_RANK</i> are similar to the <i>ROW_NUMBER</i>
function, but they produce the same ranking value in all rows that
have the same logical ordering value.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
difference between <i>RANK</i> and <i>DENSE_RANK</i> is that <i>RANK</i>
indicates how many rows have a lower ordering value, whereas
<i>DENSE_RANK</i> indicates how many distinct ordering values are
lower.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">For
example, a rank of 9 indicates eight rows with lower values. A dense
rank of 9 indicates eight distinct lower values.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
</li>
<li><div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><b>NTILE</b>
– The <i>NTILE</i> function assigns buckets to groups of rows. It
allows us to associate the rows in the result with tiles (equally
sized groups of rows) by assigning a tile number to each row. This
takes the rows from the query and places them into an equal (or as
close to equal as possible) number of specified numbered groups,
where <i>NTILE</i> returns the group number the row belongs to. The
value in parentheses after <i>NTILE</i> defines the number of groups
to produce, so <i>NTILE(25)</i> would produce 25 groups of as close
a split as possible of even numbers.</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"><i><b>Example
Query</b>:</i></span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">SELECT
<i><b>NTILE(10) OVER (ORDER BY LastName) AS BatchNumber</b></i><b>,</b>
CONCAT(FirstName,' ',LastName) AS CustomerName, UnclearedBalance</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
CustomerDetails.Customers</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">WHERE
UnclearedBalance is not null</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">ORDER
BY BatchNumber</span></span></div>
</li>
</ol>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;">The
following SQL query uses all the ranking functions in a single query:</span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: small;"> </span></span>
</div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">SELECT
orderid, custid, val,</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">ROW_NUMBER()
OVER(ORDER BY val) AS rownum,</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">RANK()
OVER(ORDER BY val) AS rank,</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">DENSE_RANK()
OVER(ORDER BY val) AS dense_rank,</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">NTILE(100)
OVER(ORDER BY val) AS ntile</span></span></div>
<div align="LEFT" style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">FROM
Sales.OrderValues</span></span></div>
<div style="font-style: normal; margin-bottom: 0in;">
<span style="font-family: Courier New, monospace;"><span style="font-size: small;">ORDER
BY val;</span></span></div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-40559777860929569702013-07-23T03:35:00.000+05:302013-09-02T09:13:26.468+05:30Differentiate between WCF and ASMX Web Service<div dir="ltr" style="text-align: left;" trbidi="on">
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">ASMX
Web Services (ASP.NET Web Service) are designed to exchange messages
only using <b><i>SOAP over HTTP</i></b>.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">However,
WCF can exchange messages using any format (SOAP is the default
format) over any transport protocol (<i><b>HTTP</b></i>, <b><i>TCP/IP</i></b>, <b><i>MSMQ</i></b>, <i><b>NamedPipes</b></i>,
etc).</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">ASMX
Web Services can only be hosted in IIS over HTTP.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">However,
WCF service can be hosted in <b><i>IIS</i></b>, <b><i>WAS</i></b> (Windows Process Activation
Services), <b><i>Console Application</i></b>, <b><i>Windows NT Services</i></b>, <b><i>WCF provided
host</i></b>.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">There
is limited security in ASMX Web Services. IIS is responsible for
authentication and authorization and ASP.NET security configuration,
and transport layer security. WSE can be used for message layer
security.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">WCF
supports many of the capabilities provided by IIS and WS-* security
models. It provides a <b><i>consistent security programming</i></b> model for any
protocol. The security provided by WCF is consistent regardless of
the host that is used to implement the service. WCF also supports
claim based authorization, that provides much better control over
resources than role based security.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">ASMX
Web Services uses <b><i>XmlSerializer</i></b> for serialization while WCF uses
<i><b>DataContractSerializer</b></i> which is far better in performance than
XmlSerializer. Major issues with XmlSerializer is as given below:</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">a) Only
public fields or properties can be translated to XML.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">b) The
classes which implements IEnumerable interface can only be
translated.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">c)
Classes that implement IDictionary such as Hashtable cannot be
serialized.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Web
Services are not as flexible as WCF services. 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.</span><br />
<span style="font-family: Arial, sans-serif;"><br /></span>
<i><span style="font-family: Arial, Helvetica, sans-serif;"><b>Note:</b> <span style="line-height: 115%;">WebService supports </span><b style="line-height: 115%;">Early
Binding</b><span style="line-height: 115%;"> while WCF supports </span><b style="line-height: 115%;">Late
Binding</b><span style="line-height: 115%;">.</span></span></i><br />
<i><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 115%;"><br /></span></span></i>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;">A <b>major advantage</b> of WCF over WebServices is that it can exchange
messages in the following patterns:<o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Arial, Helvetica, sans-serif;">1)
<!--[endif]--><b>Request –
Reply</b> Message Exchange Pattern<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Arial, Helvetica, sans-serif;">2)
<!--[endif]--><b>One – Way</b> Message
Exchange Pattern<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Arial, Helvetica, sans-serif;">3)
<!--[endif]--><b>Duplex</b> Message
Exchange Pattern<o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<i><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 115%;">
<span style="line-height: 115%;"><span style="font-size: small;">WebServices
only supports </span><b>Request – Reply</b> Message
Exchange Pattern.</span></span></span></i><br />
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 12.0pt; line-height: 115%;"><o:p></o:p></span></div>
<br /></div>
</li>
</ul>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com0tag:blogger.com,1999:blog-2696372599029490903.post-31419261951614593892013-07-07T11:36:00.002+05:302013-07-15T13:46:01.293+05:30Differentiate between Server.Transfer() & Response.Redirect()<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Both
Server.Transfer and Response.Redirect are ASP.NET objects and are
used for navigation between web-pages. However, there are noticeable
differences between these two techniques:</span></div>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>Response.Redirect()</b></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Response.Redirect()
redirects the user to another web-page which may or may not be on
the same server. It can redirect the user to an external website on
a different server.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Response.Redirect()
updates the address bar and adds the updated URL to the browser
history. User can click back on the browser to navigate to the
previous page.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Response.Redirect()
terminates the request with <b>HTTP 302</b> status and client-side
roundtrip. Client then navigates to the new address and the browser
address bar and history updates. The client pays the cost of
additional round-trips to the server on each request.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Form
variables are are not transferred upon a call to
Response.Redirect().</span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<br />
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;"><b>Server.Transfer()</b></span></div>
<ul>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Server.Transfer()
quits current execution of the web-page and redirects the user to
another web-page on the <b>same server</b>. It cannot send the user
to an external website on a different server.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Server.Transfer()
keeps the URL <b>unchanged</b> in the address bar. It happens
entirely on the server side and the client browser’s address bar
remains constant. User cannot click on back button on the browser to
navigate to the previous page</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Server.Transfer()
reduces the server request and conserves server resources. It simply
changes the focus on the Web Server and transfers the request. With
Server.Transfer() there are less number of HTTP requests, which
eases pressure on the Web Server and makes the application execute
faster.</span></div>
</li>
<li><div style="margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif;">Developer
can transfer Query Strings and form variables with a little
bug-bashing. The Server.Transfer() method has a second parameter –
<b>preserveForm</b>. If this is set to True, the existing query
string and form variables will be available to the transferred page.
Ex – <i><b>Server.Transfer(“webpage2”, True);</b></i></span></div>
</li>
</ul>
<div style="margin-bottom: 0in;">
<br />
</div>
</div>
GreenBloghttp://www.blogger.com/profile/05905617144131044273noreply@blogger.com1