tag:blogger.com,1999:blog-34167725424159932892024-01-15T17:53:28.143-06:00Atul Patel's Blog Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-3416772542415993289.post-30906155057179709092020-05-25T15:37:00.000-05:002020-05-25T15:37:13.145-05:00JSON mapping and Transform<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 class="mume-header" id="json-mapping-and-transform" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 2.25em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
JSON mapping and Transform</h1>
<div class="sync-line" data-line="2" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h2 class="mume-header" id="1-current-issue-and-requirement" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
Current Issue and requirement</h2>
<br />
Nowadays most applications are using APIs to interact with internal distributed applications or interact with 3rd party applications. A most common need of APIs are their results needs to map with different custom JSON format. If you are working in .net C# like strongly typed language then you ended up in followings to map different format JSON.<br />
<br />
1. Create Source C# POCO object<br />
2. Create Result C# POCO Object<br />
3. DeSerialize JSON to C# Object for both Source and destination class.<br />
4. Create Mapper class which can Map two C# class and generates resulted in object by mapping property with a different name. Here you can use the "Automapper" library. <br />
<br />
<div class="sync-line" data-line="10" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h2 class="mume-header" id="2-use-case-scenario" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
Use case scenario</h2>
<br />
This kind of need gets complexer when you dealing with multiple 3rd party APIs needs to map a single result type json. Here are couple of scenarios for the same.<br />
1. Air ticket booking. Invoke multiple airline apis for the ticket booking request and associates the result object and show it to users.<br />
2. Quotation or Pricing for an Item from multiple stores or vendor. <br />
3. Hotel booking etc.<br />
<br />
<div style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px; margin-bottom: 16px;">
In above use case scenarios, If you wanted to build a system that may want to add new API vendor then Developers has to do work on all the above-mentioned steps, and application implementation is not closed for maintenance. (2. Open closed principle of SOLID principles)</div>
<div class="sync-line" data-line="17" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h2 class="mume-header" id="3-solutions" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
Solutions:</h2>
For this issue I found Querying JSON with complex JSON path interesting way to map it. This is explained in [Newtonsoft Json](https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm). You can generate some kind of JSON transform JSON and can generate resulted JSON.<br />
<br />
This has been resolved by WorkMaze/JUST.net<br />
<br />
https://github.com/WorkMaze/JUST.net<br />
<br />
It uses transformation language like XSLT. It also includes functions present JUST documentation to convert values in desired output JSON.<br />
<br />
I have tried one small example myself which I explained below.<br />
They have given lots of examples and almost all cases they provided in their open-source Test/Unit Test.<br />
<br />
Microsoft also has a projected JSON transformation library called JDT - Transform JSON File using a JSON transformation file. <br />
<br />
https://github.com/microsoft/json-document-transforms<br />
<br />
It has a Wiki page also here. https://github.com/microsoft/json-document-transforms/wiki<br />
This solution is basically transforming configuration files like "appsettings.json" used in asp.net core projects and their approach is merging two files instead of just transform. for example if you have defined Source Json and Transform JSON according to JD specification, It will result in Merge of matched properties of transform and none matched properties as well. You have to mention delete specifically for each not matched or not needed property in transform. <br />
<br />
<div class="sync-line" data-line="36" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h2 class="mume-header" id="4-one-code-example" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
4. one code example</h2>
<div class="sync-line" data-line="37" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h4 class="mume-header" id="source-json" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.25em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em;">
Source JSON:</h4>
<div class="sync-line" data-line="38" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<pre class="language-" data-info="" data-role="codeBlock" style="background: rgb(245, 245, 245); border-radius: 3px; border: rgb(214, 214, 214); color: #333333; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em !important; hyphens: none; line-height: 1.4; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 0.8em; tab-size: 8; word-break: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; color: black; display: inline; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 0.85em !important; line-height: inherit; margin: 0px; max-width: initial; overflow-wrap: normal; overflow: initial; padding: 0px; word-break: normal;"> {
"Name": "Atul Patel",
"Addresses": [
{
"Address1": "234 Brewer st",
"Address2": "",
"zipcode": "75072",
"City": "Mckinney",
"State": "Texas",
"Country": "USA",
"AddressType": "PrimaryHomeAddress"
},
{
"Address1": "343 McCullam st",
"Address2": "",
"zip": "75845",
"City": "Dallas",
"State": "Texas",
"Country": "USA",
"AddressType": "OfficeAddress"
}
],
"DateOfBirth": "07/07/1980"
}
</code></pre>
<div class="sync-line" data-line="65" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h4 class="mume-header" id="transform-json" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.25em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em;">
Transform JSON:</h4>
<div class="sync-line" data-line="67" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<pre class="language-" data-info="" data-role="codeBlock" style="background: rgb(245, 245, 245); border-radius: 3px; border: rgb(214, 214, 214); color: #333333; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em !important; hyphens: none; line-height: 1.4; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 0.8em; tab-size: 8; word-break: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; color: black; display: inline; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 0.85em !important; line-height: inherit; margin: 0px; max-width: initial; overflow-wrap: normal; overflow: initial; padding: 0px; word-break: normal;"> {
"Name": "#valueof($.Name)",
"Addresse": {
"Address1": "#valueof($.Addresses[?(@.AddressType=='PrimaryHomeAddress')].Address1)",
"Address2": "#valueof($.Addresses[?(@.AddressType=='PrimaryHomeAddress')].Address2)",
"zip": "#valueof($.Addresses[?(@.AddressType=='PrimaryHomeAddress')].zipcode)",
"City": "#valueof($.Addresses[?(@.AddressType=='PrimaryHomeAddress')].City)",
"State": "#valueof($.Addresses[?(@.AddressType=='PrimaryHomeAddress')].State)",
"Country": "#valueof($.Addresses[?(@.AddressType=='PrimaryHomeAddress')].Country)"
},
"BirthDate": "#valueof($.DateOfBirth)"
}
</code></pre>
<div class="sync-line" data-line="83" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h4 class="mume-header" id="result-json" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.25em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em;">
Result JSON:</h4>
<div class="sync-line" data-line="85" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<pre class="language-" data-info="" data-role="codeBlock" style="background: rgb(245, 245, 245); border-radius: 3px; border: rgb(214, 214, 214); color: #333333; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.85em !important; hyphens: none; line-height: 1.4; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 0.8em; tab-size: 8; word-break: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; color: black; display: inline; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 0.85em !important; line-height: inherit; margin: 0px; max-width: initial; overflow-wrap: normal; overflow: initial; padding: 0px; word-break: normal;">{
"Name": "Atul Patel",
"Addresse": {
"Address1": "234 Brewer st",
"Address2": "",
"zip": "75072",
"City": "Mckinney",
"State": "Texas",
"Country": "USA"
},
"BirthDate": "07/07/1980"
}
</code></pre>
<div class="sync-line" data-line="101" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h2 class="mume-header" id="conclusion" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
Conclusion:</h2>
Using JSON.net like a library can provide a cleaner approach of mapping different JSON formats by providing a JSON transform file. Anytime you have a new source, You don't need to do and code changes. Just provide a transformation file would be enough. This is satisfying one the SOLID principle (Open-Close principle).<br />
<br />
<div class="sync-line" data-line="104" style="background-color: white; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 16px;">
</div>
<h2 class="mume-header" id="references" style="background-color: white; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.2; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em;">
References:</h2>
<br />
https://github.com/WorkMaze/JUST.net<br />
https://www.codeproject.com/Articles/1187172/JUST-JSON-Under-Simple-Transformation<br />
https://github.com/microsoft/json-document-transforms<br />
https://github.com/microsoft/json-document-transforms/wiki<br />
https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com1tag:blogger.com,1999:blog-3416772542415993289.post-30634241205308815492020-02-11T09:14:00.000-06:002020-02-11T09:14:05.641-06:00Learn SQL from zero to hero<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div>
<br /></div>
<div>
One of my friends wanted to learn SQL server and queries. I provided him a few online books for basics. This may be helpful for someone. </div>
<div>
If you want to learn queries than you must practice queries on your own. Microsoft's AdventureWorks is a really good sample database provided by Microsoft. Almost every online tutorial and videos use this database as an example. </div>
<div>
<br /></div>
<div>
here is the URL to download the Adventureworks Sample database. It also explains how to install etc.</div>
<div>
<br /></div>
<div>
<a href="https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver15">https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver15</a> </div>
<div>
<br /></div>
<div>
<a href="https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks">https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks</a> </div>
<div>
<br /></div>
<div>
Database objects like Schema, tables are explained here</div>
<div>
<br /></div>
<div>
<a href="https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/ms124425(v=sql.100)">https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/ms124425(v=sql.100)</a></div>
<div>
<br /></div>
<div>
some business scenarios explained here with Query.</div>
<div>
<br /></div>
<div>
<a href="https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/ms124825(v=sql.100)">https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/ms124825(v=sql.100)</a></div>
<div>
</div>
<div>
This is one of the great online free tools to practice Queries on the database. It has a query sample and you can see the output. It also has some assessment.</div>
<div>
<br /></div>
<div>
<a href="https://sqlzoo.net/">https://sqlzoo.net/</a> </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1uA2SQFyUroosjKXEoRXgX8Y7e4rzkI1Du2f4omK8X8noudPKDhVzNsOpuSyZyYbvE-7dcVilTaMEOy-jkPDahmzQNeJCjJb5Xbmh1ZWORk23CNrhsqynoVRrgfg5IU9g3B6qjYPDfJ8g/s1600/2020-02-11+09_10_51-Clipboard.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="741" data-original-width="1600" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1uA2SQFyUroosjKXEoRXgX8Y7e4rzkI1Du2f4omK8X8noudPKDhVzNsOpuSyZyYbvE-7dcVilTaMEOy-jkPDahmzQNeJCjJb5Xbmh1ZWORk23CNrhsqynoVRrgfg5IU9g3B6qjYPDfJ8g/s640/2020-02-11+09_10_51-Clipboard.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<br />
<div>
</div>
<br />
<div>
Enjoy SQL queries.</div>
<div>
<br /></div>
<div>
In case of any questions then please ask in comments, I will try to reply to my best.</div>
<div>
<br /></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com0tag:blogger.com,1999:blog-3416772542415993289.post-53069594411317559022019-03-08T08:54:00.000-06:002019-03-08T08:59:37.293-06:00Import - export data using Azure blob storage and bcp utility<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<a class="assistive" href="https://atlassian.cudirect.com/confluence/display/FF/Import+-+export+Azure+blob+storage#page-metadata-end" style="background-color: white; border: 0px; clip: rect(0px, 0px, 0px, 0px); color: #0052cc; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; text-decoration-line: none; width: 1px;">Skip to end of metadata</a><br />
<div class="page-metadata" style="background-color: white; color: #5e6c84; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; font-size: 12px; line-height: 1.5; margin: -15px 0px 20px; padding: 0px;">
<ul style="line-height: 16px; list-style-type: none; margin: 0px; overflow: hidden; padding: 0px;"><br /></ul>
</div>
<div class="assistive" id="page-metadata-end" style="background-color: white; border: 0px; clip: rect(0px, 0px, 0px, 0px); color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px;">
</div>
<div class="wiki-content" id="main-content" style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 0px; padding: 0px;">
<div style="padding: 0px;">
Example of the export data file, generated using BCP utility from a local SQL server, upload to Azure blob storage and import to Azure SQL server.</div>
<div style="margin-top: 10px; padding: 0px;">
we will do it in the following steps :</div>
<ol style="margin: 10px 0px 0px;">
<li>Export data from local SQL server </li>
<li>Create Azure blob storage</li>
<li>Create an Azure blob storage container</li>
<li>Upload exported files to blob storage</li>
<li>Import data from uploaded azure blob storage data file</li>
</ol>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<h2 id="Import-exportAzureblobstorage-1.ExportdatafromlocalSQLserver:" style="border-bottom-color: rgb(196, 196, 196); font-size: 20px; font-weight: normal; letter-spacing: 0px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
1. Export data from the local SQL server: </h2>
<div style="margin-top: 10px; padding: 0px;">
Using BCP utility we can export.dat file and file format file.</div>
<div style="margin-top: 10px; padding: 0px;">
You can download the latest version of BCP from <a class="external-link" href="https://docs.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">here </a>(<a class="external-link" href="https://docs.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://docs.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017</a>).</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
<sup>bcp "SELECT Name, Color, Price, Size, Quantity, Data, Tags FROM Product" queryout product.dat -S (localdb)\MSSQLLocalDB -d MemEligibiltyTest -T</sup></div>
<div style="margin-top: 10px; padding: 0px;">
Here "product.dat" is an output filename. </div>
<div style="margin-top: 10px; padding: 0px;">
-S Sql server hostname</div>
<div style="margin-top: 10px; padding: 0px;">
-d Database Name</div>
<div style="margin-top: 10px; padding: 0px;">
-T Trusted connection.</div>
<div style="margin-top: 10px; padding: 0px;">
We need to provide a format for each field. bcp asks for each field like below.</div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter prefix-length of field Name <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=2&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">2</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>: none</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter the file storage type of field Color <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=nvarchar&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">nvarchar</a>: cr</sub><br />
<sub>Enter prefix-length of field Color <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=2&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">2</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>: none</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter the file storage type of field Price <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=money&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">money</a>: cr</sub><br />
<sub>Enter prefix-length of field Price <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=1&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">1</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>: none</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter the file storage type of field Size <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=nvarchar&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">nvarchar</a>: cr</sub><br />
<sub>Enter prefix-length of field Size <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=2&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">2</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>: none</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter the file storage type of field Quantity <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=int-null&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">int-null</a>: cr</sub><br />
<sub>Enter prefix-length of field Quantity <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=1&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">1</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>: none</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter the file storage type of field Data <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=nvarchar&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">nvarchar</a>: cr</sub><br />
<sub>Enter prefix-length of field Data <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=2&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">2</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>: none</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Enter the file storage type of field Tags <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=nvarchar&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">nvarchar</a>: cr</sub><br />
<sub>Enter prefix-length of field Tags <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=2&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">2</a>: 8</sub><br />
<sub>Enter field terminator <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=none&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">none</a>:</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Do you want to save this format information in a file? <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=Y%2Fn&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">Y/n</a> y</sub><br />
<sub>Host filename <a class="createlink" href="https://atlassian.cudirect.com/confluence/pages/createpage.action?spaceKey=FF&title=bcp.fmt&linkCreation=true&fromPageId=18539127" style="color: #6d1806;">bcp.fmt</a>: product.fmt</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Starting copy...</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<sub>4 rows copied.</sub><br />
<sub>Network packet size (bytes): 4096</sub><br />
<sub>Clock Time (ms.) Total: 15 Average : (266.67 rows per sec.)</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
As I have provided prefix -length 8 for each field, generated files keeps 8 characters readable instead of binary character. You can see the rest of the characters are in binary format.</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
It creates the following two files</div>
<div style="margin-top: 10px; padding: 0px;">
This creates two files product.dat and product.fmt. 1st is the data file and another is the format file.</div>
<div style="margin-top: 10px; padding: 0px;">
product.dat looks like below.</div>
<div style="margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"><img class="confluence-embedded-image" data-base-url="https://atlassian.cudirect.com/confluence" data-image-src="/confluence/download/attachments/18539127/productdate%20file.png?version=1&modificationDate=1551930317517&api=v2" data-linked-resource-container-id="18539127" data-linked-resource-container-version="2" data-linked-resource-content-type="image/png" data-linked-resource-default-alias="productdate file.png" data-linked-resource-id="18539129" data-linked-resource-type="attachment" data-linked-resource-version="1" data-unresolved-comment-count="0" height="67" src="https://atlassian.cudirect.com/confluence/download/attachments/18539127/productdate%20file.png?version=1&modificationDate=1551930317517&api=v2" style="border: 0px; display: block; margin: 0px 2px; max-width: none; padding: 0px;" width="640" /></span></div>
<div style="margin-top: 10px; padding: 0px;">
format file.</div>
<div style="margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"><img class="confluence-embedded-image" data-base-url="https://atlassian.cudirect.com/confluence" data-image-src="/confluence/download/attachments/18539127/product.fmt%20-.png?version=1&modificationDate=1551930315303&api=v2" data-linked-resource-container-id="18539127" data-linked-resource-container-version="2" data-linked-resource-content-type="image/png" data-linked-resource-default-alias="product.fmt -.png" data-linked-resource-id="18539128" data-linked-resource-type="attachment" data-linked-resource-version="1" data-unresolved-comment-count="0" height="113" src="https://atlassian.cudirect.com/confluence/download/attachments/18539127/product.fmt%20-.png?version=1&modificationDate=1551930315303&api=v2" style="border: 0px; display: block; margin: 0px 2px; max-width: none; padding: 0px;" width="640" /></span></div>
<h2 id="Import-exportAzureblobstorage-2.CreateAzureblobstorage" style="border-bottom-color: rgb(196, 196, 196); font-size: 20px; font-weight: normal; letter-spacing: 0px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
2. Create Azure blob storage</h2>
<div style="margin-top: 10px; padding: 0px;">
we will use Powershell for azure connection.</div>
<div style="margin-top: 10px; padding: 0px;">
Azure PowerShell works with PowerShell 5.1 or higher on Windows or PowerShell 6 on any platform. To check your PowerShell version, run the command:</div>
<div style="margin-top: 10px; padding: 0px;">
<sub>$PSVersionTable.PSVersion</sub></div>
<div style="margin-top: 10px; padding: 0px;">
You can install Powershell Azure module using the following command</div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Install-Module -Name Az -AllowClobber</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<br />
Connect to Azure with a browser sign in token</div>
<div style="margin-top: 10px; padding: 0px;">
<sub>Connect-AzAccount</sub></div>
<div style="margin-top: 10px; padding: 0px;">
o/p:</div>
<div style="margin-top: 10px; padding: 0px;">
<sup>Account SubscriptionName TenantId Environment</sup><br />
<sup>------- ---------------- -------- -----------</sup><br />
<sup><a class="external-link" href="mailto:Atul.Patel@cudirect.com" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">Atulxxxxxxx@xxxxxx.com</a> ABCD - Development dxxxxxx3-xxxx-xxxx-xxxx-xxxxxxxxxxxx AzureCloud</sup></div>
<div style="margin-top: 10px; padding: 0px;">
As you logged in to Azure and it shows the default subscription. If you want to execute everything in another subscription then need to select that subscription.</div>
<div style="margin-top: 10px; padding: 0px;">
You can get an Azure subscription by subscription id using the following command.</div>
<div style="margin-top: 10px; padding: 0px;">
PS C:\Windows\system32> $context = Get-AzSubscription -subscriptionId <span style="font-size: 11.6667px;">xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</span></div>
<div style="margin-top: 10px; padding: 0px;">
You can store output to a variable and use same variable to set Azure context to select particular azure subscription.</div>
<div style="margin-top: 10px; padding: 0px;">
command:</div>
<div style="margin-top: 10px; padding: 0px;">
PS C:\Windows\system32> set-AzContext $context</div>
<div style="margin-top: 10px; padding: 0px;">
o/p:</div>
<div style="margin-top: 10px; padding: 0px;">
Name Account SubscriptionName Environment TenantId<br />
---- ------- ---------------- ----------- --------<br />
ABCD (xxxxxxxx-xxxx-xxx... Atul.Patel@xxxx... ABCD AzureCloud xxxxxxxx-xxxx-x...</div>
<div style="margin-top: 10px; padding: 0px;">
Define a variable for the resource group.</div>
<div style="margin-top: 10px; padding: 0px;">
<sub>$resourceGroupName="your-resource-group-name"</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<span style="font-size: 11.6667px;">$blobStorageAccountName="yourblobstorageaccountname"</span></div>
<div style="margin-top: 10px; padding: 0px;">
You can create a New Azure storage account using the following command. You can store azure account context to a variable.<br />
PS C:\Windows\system32> $storageAccount=New-AzStorageAccount -ResourceGroup $resourceGroupName -Name <span style="font-size: 11.6667px;">$blobStorageAccountName</span> -skuname Standard_LRS -Location WestUS2</div>
<div style="margin-top: 10px; padding: 0px;">
o/p:</div>
<div style="margin-top: 10px; padding: 0px;">
StorageAccountName ResourceGroupName Location SkuName Kind AccessTier CreationTime ProvisioningState<br />
------------------ ----------------- -------- ------- ---- ---------- ------------ -----------<br />
<span style="font-size: 11.6667px;">yourblobstorageaccountname</span> <span style="font-size: 11.6667px;">your-resource-group-name</span> westus2 StandardLRS Storage 3/5/2019 8:55:10 PM Succeeded</div>
<div style="margin-top: 10px; padding: 0px;">
If you already have a azure storage account then you can get it using following command.</div>
<div style="margin-top: 10px; padding: 0px;">
PS C:\Windows\system32> $storageAccount=Get-AzStorageAccount -ResourceGroup $resourceGroupName -Name <span style="font-size: 11.6667px;">$blobStorageAccountName</span></div>
<div style="margin-top: 10px; padding: 0px;">
PS C:\Windows\system32> $storageAccount</div>
<div style="margin-top: 10px; padding: 0px;">
o/p:</div>
<div style="margin-top: 10px; padding: 0px;">
StorageAccountName ResourceGroupName Location SkuName Kind AccessTier CreationTime ProvisioningState<br />
------------------ ----------------- -------- ------- ---- ---------- ------------ -----------<br />
<span style="font-size: 11.6667px;">yourblobstorageaccountname</span> <span style="font-size: 11.6667px;">your-resource-group-name</span> westus2 StandardLRS Storage 3/5/2019 8:55:10 PM Succeeded</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<h2 id="Import-exportAzureblobstorage-3.CreateAzureblobstoragecontainer" style="border-bottom-color: rgb(196, 196, 196); font-size: 20px; font-weight: normal; letter-spacing: 0px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
3. Create an Azure blob storage container</h2>
<div style="margin-top: 10px; padding: 0px;">
Storing storage account context into variable</div>
<div style="margin-top: 10px; padding: 0px;">
$ctx=$storageAccount.Context<br />
<br />
-- Variable for Container name<br />
$containerName="yourcontainername"<br />
<br />
Create new container using following command:<br />
new-AzStorageContainer -Name $containerName -Context $ctx</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
o/p:<br />
Blob End Point: <a class="external-link" href="https://yourblobstorageaccountname.blob.core.windows.net/" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://<span style="color: #172b4d; font-size: 11.6667px;">yourblobstorageaccountname</span>.blob.core.windows.net/</a></div>
<div style="margin-top: 10px; padding: 0px;">
Name PublicAccess LastModified<br />
---- ------------ ------------<br />
blogstoragename Off 3/5/2019 8:59:56 PM +00:00</div>
<div style="margin-top: 10px; padding: 0px;">
context looks like below:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZZXg-iIYX58ljeokroZYqbelVfISHKx_vJd7Ag69egEH6XorUcY2kiorLpV6DzTFgZ0wTiAgBhbLLBQnD4ztwb1XpXY-756czOFUxxKA5ZOTvLH3juoHFymMWwpBqZsZQxKUUgRxKW6BH/s1600/2019-03-07+10_53_03-CUD+DEV+L360+Pool.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="293" data-original-width="944" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZZXg-iIYX58ljeokroZYqbelVfISHKx_vJd7Ag69egEH6XorUcY2kiorLpV6DzTFgZ0wTiAgBhbLLBQnD4ztwb1XpXY-756czOFUxxKA5ZOTvLH3juoHFymMWwpBqZsZQxKUUgRxKW6BH/s640/2019-03-07+10_53_03-CUD+DEV+L360+Pool.png" width="640" /></a></div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"></span></div>
<h2 id="Import-exportAzureblobstorage-4.Uploadexportedfilestoblobstorage" style="border-bottom-color: rgb(196, 196, 196); font-size: 20px; font-weight: normal; letter-spacing: 0px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
4. Upload exported files to blob storage</h2>
<div style="margin-top: 10px; padding: 0px;">
You can use the same Azure blob storage container context to upload files.</div>
<div style="margin-top: 10px; padding: 0px;">
command:<br />
<sub>set-AzStorageblobcontent -File "C:\Users\atul.patel\product.fmt" `</sub><br />
<sub>-Container $containerName `</sub><br />
<sub>-Blob "product.fmt" `</sub><br />
<sub>-Context $ctx</sub></div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
o/p:</div>
<div style="margin-top: 10px; padding: 0px;">
Container Uri: <a class="external-link" href="https://yourblobstorageaccountname.blob.core.windows.net/blogstoragename" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://<span style="color: #172b4d; font-size: 11.6667px;">yourblobstorageaccountname</span>.blob.core.windows.net/</a>blogstoragename</div>
<div style="margin-top: 10px; padding: 0px;">
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted<br />
---- -------- ------ ----------- ------------ ---------- ------------ ---------<br />
product.fmt BlockBlob 755 application/octet-stream 2019-03-05 21:37:54Z Unknown False</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
Another file.</div>
<div style="margin-top: 10px; padding: 0px;">
set-AzStorageblobcontent -File "C:\Users\atul.patel\product.dat" `<br />
-Container $containerName `<br />
-Blob "product.dat" `<br />
-Context $ctx</div>
<div style="margin-top: 10px; padding: 0px;">
o/p:</div>
<div style="margin-top: 10px; padding: 0px;">
Container Uri: <a class="external-link" href="https://yourblobstorageaccountname.blob.core.windows.net/appqappinfoblob" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://<span style="color: #172b4d; font-size: 11.6667px;">yourblobstorageaccountname</span>.blob.core.windows.net/</a>blogstoragename</div>
<div style="margin-top: 10px; padding: 0px;">
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted<br />
---- -------- ------ ----------- ------------ ---------- ------------ ---------<br />
product.dat BlockBlob 456 application/octet-stream 2019-03-05 21:38:08Z Unknown False</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
Select list of upload files on Azure blob storage container.</div>
<div style="margin-top: 10px; padding: 0px;">
PS C:\Windows\system32> Get-AzStorageBlob -Container $containerName -Context $ctx | select Name</div>
<div style="margin-top: 10px; padding: 0px;">
Name<br />
----<br />
product.dat<br />
product.fmt</div>
<h2 id="Import-exportAzureblobstorage-5.Importdatafromuploadedazureblobstoragedatafile" style="border-bottom-color: rgb(196, 196, 196); font-size: 20px; font-weight: normal; letter-spacing: 0px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
5.Import data from uploaded azure blob storage data file</h2>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
** Import data into Sql server db from azure blob storage<br />
<br />
-- Import into DB<br />
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'XXXXXXXXxxxxxxxxxxxxXXX'<br />
<br />
-- Create credential with Azure Blob SAS<br />
<br />
CREATE DATABASE SCOPED CREDENTIAL youcredentialname<br />
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',<br />
SECRET = 'sv=2018-03-28&ss=bfqt&srt=sco&sp=xxxxxxxxxx&se=2019-03-06T23:30:14Z&st=2019-03-06T15:30:14Z&spr=https&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';<br />
-- NOTE: DO NOT PUT FIRST CHARACTER '?'' IN SECRET!!!</div>
<div style="margin-top: 10px; padding: 0px;">
<br />
-- Create external data source<br />
CREATE EXTERNAL DATA SOURCE blogstoragename<br />
WITH ( TYPE = BLOB_STORAGE,<br />
LOCATION = '<a class="external-link" href="https://yourblobstorageaccountname.blob.core.windows.net/blogstoragename" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://<span style="color: #172b4d; font-size: 11.6667px;">yourblobstorageaccountname</span>.blob.core.windows.net/</a>blogstoragename',<br />
CREDENTIAL= youcredentialname --> CREDENTIAL is not required if a blob storage is public!<br />
);<br />
<br />
--Create table<br />
<br />
CREATE TABLE dbo.Product(<br />
Name nvarchar(50) NOT NULL,<br />
Color nvarchar(15) NULL,<br />
Price money NOT NULL,<br />
Size nvarchar(5) NULL,<br />
Quantity int NULL,<br />
Data nvarchar(4000) NULL,<br />
Tags nvarchar(4000) NULL<br />
)<br />
<br />
BULK INSERT Product<br />
FROM 'product.dat'<br />
WITH ( DATA_SOURCE = 'blogstoragename',<br />
FORMATFILE='product.fmt',<br />
FORMATFILE_DATA_SOURCE = 'blogstoragename',<br />
TABLOCK);</div>
<div style="margin-top: 10px; padding: 0px;">
--Just select<br />
SELECT Name, Color, Price, Size, Quantity, Data, Tags<br />
FROM OPENROWSET(BULK 'product.dat',<br />
DATA_SOURCE = 'blogstoragename',<br />
FORMATFILE='product.fmt',<br />
FORMATFILE_DATA_SOURCE = 'blogstoragename') as products;</div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<div style="margin-top: 10px; padding: 0px;">
<br /></div>
<h2 id="Import-exportAzureblobstorage-References:" style="border-bottom-color: rgb(196, 196, 196); font-size: 20px; font-weight: normal; letter-spacing: 0px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
References:</h2>
<div style="margin-top: 10px; padding: 0px;">
<a class="external-link" href="https://azure.microsoft.com/en-us/updates/files-from-azure-blob-storage-to-sql-database/" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://azure.microsoft.com/en-us/updates/files-from-azure-blob-storage-to-sql-database/</a></div>
<div style="margin-top: 10px; padding: 0px;">
<a class="external-link" href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-powershell" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-powershell</a></div>
<div style="margin-top: 10px; padding: 0px;">
<a class="external-link" href="https://docs.microsoft.com/en-us/powershell/module/az.storage/new-AzStoragecontainer?view=azps-1.4.0" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://docs.microsoft.com/en-us/powershell/module/az.storage/new-AzStoragecontainer?view=azps-1.4.0</a></div>
<div style="margin-top: 10px; padding: 0px;">
<a class="external-link" href="https://github.com/Microsoft/sql-server-samples/blob/master/samples/features/sql-bulk-load/load-from-azure-blob-storage/LoadFromAzureBlobStorage.sql" rel="nofollow" style="color: #0052cc; text-decoration-line: none;">https://github.com/Microsoft/sql-server-samples/blob/master/samples/features/sql-bulk-load/load-from-azure-blob-storage/LoadFromAzureBlobStorage.sql</a></div>
<div style="margin-top: 10px; padding: 0px;">
<a class="external-link" href="https://azure.microsoft.com/en-us/updates/preview-loading-files-from-azure-blob-storage-into-sql-database/" rel="nofollow" style="color: #0052cc; letter-spacing: 0px; text-decoration-line: none;">https://azure.microsoft.com/en-us/updates/preview-loading-files-from-azure-blob-storage-into-sql-database/</a></div>
<div style="margin-top: 10px; padding: 0px;">
</div>
</div>
<div id="likes-and-labels-container" style="background-color: white; clear: both; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 10px 0px; overflow: hidden; padding: 10px 0px;">
<div class="no-print" id="likes-section" style="color: #3f4c66; float: left; font-size: 12px; margin: 0px; padding: 0px; width: 488.25px;">
<a class="like-button" href="https://atlassian.cudirect.com/confluence/display/FF/Import+-+export+Azure+blob+storage" style="color: #0052cc; display: block; float: left; text-decoration-line: none;"><span class="aui-icon aui-icon-small aui-iconfont-like" style="background-position: 0px 0px; background-repeat: no-repeat; border: none; color: #505f79; display: inline-block; height: 16px; line-height: 0; margin: 0px; padding: 0px; position: relative; text-indent: -999em; vertical-align: text-top; width: 16px;"></span></a></div>
</div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com2tag:blogger.com,1999:blog-3416772542415993289.post-90036628902041836252019-01-21T16:34:00.000-06:002019-02-10T00:28:21.387-06:00SQL server JSON using practical scenario with .Net Core, C# and Dapper<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Since SQL server 2016, come up with good support of JSON save. You can find many syntactical tutorials online. My point to add one more to get an idea where should we use it and where exactly it fits best.<br />
We may have already tasted NoSql DBS like Mongo Db (big list from each cloud vendor).<br />
If you are exposing your data via API as JSON then why not store as JSON.<br />
<br />
Lets Jump in example<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVT_O2iut2y2M0pRJuV8s7XqliT2uo1IlH1pfgzolZvIrliXe8jEDQGI8sja50KpoG9lgH5DJ3FO-xqogy4fyNBfJM0B4EYlHzMyeicj1BxhgRuB1mfBZ37YZiY8Q8KM1z35QiJf83aYjw/s1600/Architectural+Diagram.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="499" data-original-width="811" height="392" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVT_O2iut2y2M0pRJuV8s7XqliT2uo1IlH1pfgzolZvIrliXe8jEDQGI8sja50KpoG9lgH5DJ3FO-xqogy4fyNBfJM0B4EYlHzMyeicj1BxhgRuB1mfBZ37YZiY8Q8KM1z35QiJf83aYjw/s640/Architectural+Diagram.png" width="640" /></a></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;"><br />
</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;"><br />
</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;">In my example, I have created a controller of Customer and CustomerContact. I have a service folder and each action has its own service class. I have used Dapper a lightweight ORM to interact with a database. This architecture is inspired by Jimmy Bogard's slice based architecture. I have left a URL to understand sliced based architecture below in the reference section.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 13.5pt;">In each service, the class has its own Query/Command model class and its own handler. <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;"> </span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 13.5pt;">Here are my basic model Customer and CustomerContact.<o:p></o:p></span></div>
</div>
<span id="goog_170761108"></span><span id="goog_170761109"></span> <br />
<div align="center" class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;">
<br /></div>
<h3 style="text-align: left;">
Customer and Customer Contact.</h3>
Note: code url is given below in the reference section.<br />
<br />
Here we assumed Customer is basically a company. For each customer, It may have multiple CustomerContacts. You can have different tables in the database for Customer and CustomerContacts and have a strong relationship between them with referential constraint.<br />
<br />
For the current example, we can have both Customer and Customer contact in the same table as Object graph by having a CustomerContacts column as a JSON under the Customer table.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIDI3wbt-AMHIP-Kqw1ifElvzHul9fDwXWuyEG_UYFYKBQN9UlT5Y9VBBuA2pwIxuzO0gi4uY6DusgvVk1MlXdS0M4vguBNZd6WuD-xOThcyCavTaJ3tM48ykIOXPnNCokwMR7vYAt9ZEr/s1600/CustomerClass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="183" data-original-width="575" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIDI3wbt-AMHIP-Kqw1ifElvzHul9fDwXWuyEG_UYFYKBQN9UlT5Y9VBBuA2pwIxuzO0gi4uY6DusgvVk1MlXdS0M4vguBNZd6WuD-xOThcyCavTaJ3tM48ykIOXPnNCokwMR7vYAt9ZEr/s1600/CustomerClass.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" data-original-height="250" data-original-width="396" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdiJ8S2h8vr3YuJ46_duPCRfB-SHnwKWAcac0-SM2Wcf8QF1XwPGu1FN6g394X1ShXWAvlurf52dd0Q-at-KR73uzR_cVFmgFQrGw1ZpkYGIIa7LrDZP3ubI_dkgYuUhCQ82UwTMCb4FQj/s1600/CustomerContactClass.png" /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdiJ8S2h8vr3YuJ46_duPCRfB-SHnwKWAcac0-SM2Wcf8QF1XwPGu1FN6g394X1ShXWAvlurf52dd0Q-at-KR73uzR_cVFmgFQrGw1ZpkYGIIa7LrDZP3ubI_dkgYuUhCQ82UwTMCb4FQj/s1600/CustomerContactClass.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"> </a></div>
<br />
<br />
Infrastructure background used in the example.<br />
<br />
<h3 style="text-align: left;">
1. Create Customer</h3>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 13.5pt;">Following is my post-action under the controller.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "times new roman" , serif; font-size: 13.5pt;"><br /></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 5.0pt;">
<span style="background: black; color: white; font-family: "times new roman" , serif; font-size: 13.5pt;"> [HttpPost]<br /> public async Task<int> Post(Customer customer)<br /> {<br /> return await _createCustomer.Handler(customer);<br /> }</span><span style="font-family: "times new roman" , serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<br />
In the above controller, I have injected ICreateCustomer and assigned it to variable _createCustomer.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcoOb1B0asGXQJ40LvKl2PODwvNe81QPnZ5kdh_w64aZ0Hu-ud61joo8l4IFN3S7mRtdkP96eSXU_duXrRuOiYzgMqwNKbOOffKhRkmNR21MISJS8jtkuzshzbc5guQZlw-VlLrfZUtK5C/s1600/CreateCustomerClass.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="724" data-original-width="1307" height="354" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcoOb1B0asGXQJ40LvKl2PODwvNe81QPnZ5kdh_w64aZ0Hu-ud61joo8l4IFN3S7mRtdkP96eSXU_duXrRuOiYzgMqwNKbOOffKhRkmNR21MISJS8jtkuzshzbc5guQZlw-VlLrfZUtK5C/s640/CreateCustomerClass.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br />
<div style="text-align: left;">
<span style="font-family: "verdana" , sans-serif;">CreateCustomer has IDbConnection injected, which is a SqlConnection instance created on a startup class of asp.net core as transient.</span></div>
</td></tr>
</tbody></table>
<span style="background-color: black; color: white;">services.AddScoped(typeof(IDbConnection), x => ( new SqlConnection(Configuration.GetConnectionString("SQLJsonDBConnectionString"))));</span><br />
<br />
<br />
<b>Command:</b><br />
We have a Handler method in CreateCustomer service. The handler can handler a command passed as an argument of the method. You can either create separate CreateCustomerCommand and map it to Model attached to a database and expose only those properties to Controller available in command.<br />
<br />
<b>Dapper:</b><br />
<br />
Dapper is a lightweight ORM which extends the IDbConnection interface. In the above Create Customer example, We have used a QuerySingleAsync method which can execute SQL statement and return the result as a single value.<br />
You can get more methods from here.:<br />
<b>Url:</b><br />
<div style="text-align: left;">
<a href="https://github.com/StackExchange/Dapper">https://github.com/StackExchange/Dapper</a></div>
<div style="text-align: left;">
<a href="https://dapper-tutorial.net/dapper">https://dapper-tutorial.net/dapper</a> </div>
<br />
In the above example, we have used a simple Insert Query with Output as newly created Id.<br />
<br />
<b>Serialize an object to JSON:</b><br />
As we wanted to store CustomerContact as a JSON, we need to serialize it using JsonConvert.SerializeObject(Object).<br />
<br />
<br />
<b>Postman</b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/blogger.g?blogID=3416772542415993289" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikUfJQcmpb0GaEYj-u2gUlm4baJrl8QyvfucvS4RF_OzRycXmT7FMlqxXOM-U4nJQKQ_BoULvLPNhamXNZc5k68fhp-ErCne8EvSq0Rdr4Ys5S_n47N2a0ZekszkZSqnVo-i90WJ4Fsg9j/s1600/1A_CreateCustomerPostman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="567" data-original-width="866" height="418" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikUfJQcmpb0GaEYj-u2gUlm4baJrl8QyvfucvS4RF_OzRycXmT7FMlqxXOM-U4nJQKQ_BoULvLPNhamXNZc5k68fhp-ErCne8EvSq0Rdr4Ys5S_n47N2a0ZekszkZSqnVo-i90WJ4Fsg9j/s640/1A_CreateCustomerPostman.png" width="640" /></a></div>
<br />
Our CreateCustomer command looks like above from postman.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheVKKM_rnzxuYZtqQHH6pCVsIMU919IAxXo9FMDOreM8IQU1ko6a52YHhdmqLEh2eLsj8oMMkFPLZ_YbQU6_OziXg52rJnfhlgIlWPW6zohq9u_dNaw8oMzqdsOMg5OO4834yr6wa8P7_P/s1600/CreateCustomer_GetSql.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="69" data-original-width="1600" height="27" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheVKKM_rnzxuYZtqQHH6pCVsIMU919IAxXo9FMDOreM8IQU1ko6a52YHhdmqLEh2eLsj8oMMkFPLZ_YbQU6_OziXg52rJnfhlgIlWPW6zohq9u_dNaw8oMzqdsOMg5OO4834yr6wa8P7_P/s640/CreateCustomer_GetSql.png" width="640" /></a></div>
In a SQL server, it looks like this.<br />
<br />
<br />
<h3 style="text-align: left;">
2. Get Customer</h3>
<br />
We have created a customer, now let's do get Customer.<br />
<br />
<b>Query Object:</b><br />
As we tried to follow the SOLID principle, We will create another Service as GetCustomers and it has its own Query and Response Model.<br />
<br />
<span style="background-color: black; color: white;">public class CustomerResponseModel</span><br />
<span style="background-color: black; color: white;"> {</span><br />
<span style="background-color: black; color: white;"> public int Id { get; set; }</span><br />
<span style="background-color: black; color: white;"> public string Name { get; set; }</span><br />
<span style="background-color: black; color: white;"> public bool Active { get; set; }</span><br />
<span style="background-color: black; color: white;"> public string CustomerContacts { get; set; }</span><br />
<span style="background-color: black; color: white;"> }</span><br />
<span style="background-color: black; color: white;"> public class Query</span><br />
<span style="background-color: black; color: white;"> {</span><br />
<span style="background-color: black; color: white;"> public int Id { get; set; }</span><br />
<span style="background-color: black; color: white;"> }</span><br />
<br />
<b>SQL:</b><br />
We will have a simple Select query as a SQL statement with Id as a Parameter passed from the Query object.<br />
<b><br /></b> <b>Dapper:</b><br />
QueryAsync with ResponseModel as a generic type parameter gives a list of CustomerResponseMdoel.<br />
Here select fields and ResponseModel property Name should be matched.<br />
<br />
<b>Response:</b><br />
To get response into CustomerContact model, We can do JsonConvert.Deserialize<ResponseModel>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQuSWN8zrUvLFhnu9Yuy3peV6Q4ekkOy5YDN-3YjUk7PafNdZG24d83SoCRqC0HLeOqEL-aWImBzLcdQMhMfuNUvh18uw0_Elyd3cR3iStzW7NKSBfrXjSdOesGpnFKEvRHlHHgdIb84sy/s1600/2_GetCustomerClass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="680" data-original-width="1148" height="378" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQuSWN8zrUvLFhnu9Yuy3peV6Q4ekkOy5YDN-3YjUk7PafNdZG24d83SoCRqC0HLeOqEL-aWImBzLcdQMhMfuNUvh18uw0_Elyd3cR3iStzW7NKSBfrXjSdOesGpnFKEvRHlHHgdIb84sy/s640/2_GetCustomerClass.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<b>Postman</b><br />
<br />
The client won't notice what conversion or way we have stored our data into the database. The response looks the same.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXr9s-YDGplfjri5rzpUqnQ49i_1vv6byLTstMcdRrB93yDfWP8BzulGU_e1LEyJOZkz8AlK6LkPmK7oABqWbFyKEO0XM9ZOjMivV9M_8NckX8Z67mk_5-FIRIxFYGYDIJpF_zZ4PCWfrp/s1600/2A_GetCustomer_Postman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="780" data-original-width="1389" height="358" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXr9s-YDGplfjri5rzpUqnQ49i_1vv6byLTstMcdRrB93yDfWP8BzulGU_e1LEyJOZkz8AlK6LkPmK7oABqWbFyKEO0XM9ZOjMivV9M_8NckX8Z67mk_5-FIRIxFYGYDIJpF_zZ4PCWfrp/s640/2A_GetCustomer_Postman.png" width="640" /></a></div>
<br />
<br />
<h3 style="text-align: left;">
3. Create customer as dynamic Customer contact.</h3>
In the above example, We have seen that we can Insert data as JSON when we have fixed CustomerContact object properties. Another advantage of having a JSON format in the database is, we can add any number of properties regardless of any fixed schema.<br />
JSON format data stored is a schema-less data store.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT8VWHEeIUCGIOs1JodIK6oUi53GMussScN7YBhqrNPyCxGDaFsqI6LtAkj4VaAfac8e8a0V4u55RJ2ws3yjTDn9KUiL5ba8wZQPI66cQmZNdmyP8HSc7toJdiq9pzzZXOA92iNFAERHVP/s1600/3_CreateCustomerDynamic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="712" data-original-width="1074" height="424" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT8VWHEeIUCGIOs1JodIK6oUi53GMussScN7YBhqrNPyCxGDaFsqI6LtAkj4VaAfac8e8a0V4u55RJ2ws3yjTDn9KUiL5ba8wZQPI66cQmZNdmyP8HSc7toJdiq9pzzZXOA92iNFAERHVP/s640/3_CreateCustomerDynamic.png" width="640" /></a></div>
<br />
CreateCustomerCommand:<br />
CreateCustomerCommand is just looking like a Customer object only one property for CustomerContacts as dynamic.<br />
<br />
<b>SQL:</b> SQL is the same as we did for fixed Schema.<br />
<br />
<b>Dapper:</b> QuerySingleAsync with the int return type. Only we have to Serialize a dynamic object to JSON before save it.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKHkzMMd4jhU26SjPGgkb21AFObbwSnjbCNYhQOceZ7xbV_wGiT64CZLqen8b0Byfv6m5oYrnZrHp90oppyGar-f13XDaJV2F3xcx-_k8K8I4CaCCYQKObvIe8dqDa_pMyrHJCr7U-TiqG/s1600/3_CreateCustomerDynamic_Postman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="679" data-original-width="1513" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKHkzMMd4jhU26SjPGgkb21AFObbwSnjbCNYhQOceZ7xbV_wGiT64CZLqen8b0Byfv6m5oYrnZrHp90oppyGar-f13XDaJV2F3xcx-_k8K8I4CaCCYQKObvIe8dqDa_pMyrHJCr7U-TiqG/s640/3_CreateCustomerDynamic_Postman.png" width="640" /></a></div>
<br />
Postman: While posting CreateCustomer, you can add any required new properties regardless of any schema.<br />
<br />
<b>Disadvantage:</b> In this approach, Schema normally controlled by UI which is not a good thing. If it exposed without security, it allows any junk data. You have to be careful while implementing this approach.<br />
I still recommend that even if you have a requirement of having dynamic properties, then also have some schema at Model level. You still don't have to worry about schema changes in the database for newly added fields.<br />
<br />
<br />
<h3 style="text-align: left;">
4. Get customer as dynamic</h3>
<br />
Similar way you can get Customer with dynamic CustomerContacts.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmcGfPFdX6AURyo56J6tS205YHXXuddVyoI_dqJ8P3adPKPpmEvtwlFB5rw7E35k8-j5p5VnOXZHxRH0DoMzNLdEJb92rTl1Wcnir3r99rZH4XUlNfaAotlMX9JehzWYbHily2eghcKEj6/s1600/4_GetCustomerDynamic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="705" data-original-width="1151" height="392" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmcGfPFdX6AURyo56J6tS205YHXXuddVyoI_dqJ8P3adPKPpmEvtwlFB5rw7E35k8-j5p5VnOXZHxRH0DoMzNLdEJb92rTl1Wcnir3r99rZH4XUlNfaAotlMX9JehzWYbHily2eghcKEj6/s640/4_GetCustomerDynamic.png" width="640" /></a></div>
with Similar SQL statement, you just need to deserialize JSON into a dynamic object using. JsonConvert.Deserialize<dynamic>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsVcUu8eVxRsF6Hee1klE49oOfQl_E2DbjZjitKtXXjd_dun_WEiHXBS4-PMq02Ymnh6Fqmk77Vk2VzQCsxyWPPoPBNqZ5OY_hxekKhTErNhTN7fIkY7tQF1pzc-_N5IKeXwfh1d0iuHdt/s1600/4_GetCustomerDynamic_Postman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="796" data-original-width="1401" height="362" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsVcUu8eVxRsF6Hee1klE49oOfQl_E2DbjZjitKtXXjd_dun_WEiHXBS4-PMq02Ymnh6Fqmk77Vk2VzQCsxyWPPoPBNqZ5OY_hxekKhTErNhTN7fIkY7tQF1pzc-_N5IKeXwfh1d0iuHdt/s640/4_GetCustomerDynamic_Postman.png" width="640" /></a></div>
This is a little safer in case you have a dynamic object with additional properties.<br />
<br />
<br />
<h3 style="text-align: left;">
5. Add Customer contact</h3>
<br />
We have Customer and we saved CustomerContacts as a JSON array object int SQL. If we have to add one more element into the same JSON array then you can use JSON_Modify() function.<br />
<br />
<b>CreateCustomerContactCommand:</b><br />
This can be command class having properties of CustomerId and CustomerContact.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZPVUNc0Lynyyzcm9jaWJ1pYPdBd6jWUXa5Y6-vl6WR7DFTRnuiPjZFwes9MwG7f1wnrczjBb-xNy61kEfL7jI52I6K5mC_CXzZR953hkdUHNV-LAKTTuCnv1w_vTOHGHhImzOREUQUflN/s1600/5_AddCustomerCommand.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="630" data-original-width="1056" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZPVUNc0Lynyyzcm9jaWJ1pYPdBd6jWUXa5Y6-vl6WR7DFTRnuiPjZFwes9MwG7f1wnrczjBb-xNy61kEfL7jI52I6K5mC_CXzZR953hkdUHNV-LAKTTuCnv1w_vTOHGHhImzOREUQUflN/s1600/5_AddCustomerCommand.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<blockquote class="tr_bq" style="clear: both;">
<b>SQL:</b><br />
<blockquote class="tr_bq">
var sql = @"UPDATE [dbo].[Customer]<br />
SET [CustomerContacts] = JSON_MODIFY(CustomerContacts,'append$',JSON_QUERY(@CustomerContact,'$')) </blockquote>
</blockquote>
<blockquote class="tr_bq" style="clear: both;">
<blockquote class="tr_bq">
WHERE Id=@CustomerId";</blockquote>
</blockquote>
<br />
JSON_MODIFY command can add one more element to existing JSON and update the same row.<br />
JSON_QUERY is useful to insert pure JSON object instead of JSON string with "\" escape sequence injected.<br />
More technical details of the function explained here.<br />
<br />
<a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/json-modify-transact-sql?view=sql-server-2017">https://docs.microsoft.com/en-us/sql/t-sql/functions/json-modify-transact-sql?view=sql-server-2017</a><br />
<a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/json-query-transact-sql?view=sql-server-2017">https://docs.microsoft.com/en-us/sql/t-sql/functions/json-query-transact-sql?view=sql-server-2017</a><br />
<br />
If JSON object inserted without JSON_Query then it looks like below highlighted.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgrjV3xDboSnP8_OFt7wXtBceOmaZmu8jKN1ZyCGK6HFsO0uW75xZzHkWc04m5lwd6npcdCPeYDmTLgyEDMTQ4qOLRKVYYfXgJ23DNo9965BdKpfQb7txSl8uAe6gSpb9xt2YrDeK4yDYL/s1600/DynamicAddError.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="399" data-original-width="1600" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgrjV3xDboSnP8_OFt7wXtBceOmaZmu8jKN1ZyCGK6HFsO0uW75xZzHkWc04m5lwd6npcdCPeYDmTLgyEDMTQ4qOLRKVYYfXgJ23DNo9965BdKpfQb7txSl8uAe6gSpb9xt2YrDeK4yDYL/s640/DynamicAddError.png" width="640" /></a></div>
<br />
<b>Postman:</b><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPifbpLjtVuDJHU8WKR5-seWzJEqbe51ATZwAM3R2_jQ11bLOlD5Hy539dKnmwYUHKVJK3JBC4fOxBTKVVQIDvylU2PwwhsBR04ahluQBsh4Nz0DhyphenhyphenlR6hingLZQQ3Ue2RmsjCjlmLJ0Uv/s1600/5_AddCustomerCommand_Postman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="683" data-original-width="1400" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPifbpLjtVuDJHU8WKR5-seWzJEqbe51ATZwAM3R2_jQ11bLOlD5Hy539dKnmwYUHKVJK3JBC4fOxBTKVVQIDvylU2PwwhsBR04ahluQBsh4Nz0DhyphenhyphenlR6hingLZQQ3Ue2RmsjCjlmLJ0Uv/s640/5_AddCustomerCommand_Postman.png" width="640" /></a></div>
<br />
<br />
<h3 style="text-align: left;">
6. Get customer contacts</h3>
<br />
If you wanted to get only Customer contact then you need to use OPENJSON function of SQL server.<br />
<br />
<b>GetCustomerContactQuery:</b><br />
The query has all the parameter you wanted to pass. In our case CustomerId is important.<br />
<b><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPTQOy7MxUt2_V_yCGF8mnb-UorMfFbnAdMm-p6YsOxtV47DWJuOTEVgnbxP5gkmbc_HxLDOTEyG5Vvqe0rGPd92Od-zCqH1o6B-RhpCBn6zIyjjIQSWoOkoKjwrV4Y8xkCV7oPQf4HjVX/s1600/GetCustomerContact+Dynamic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="613" data-original-width="910" height="430" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPTQOy7MxUt2_V_yCGF8mnb-UorMfFbnAdMm-p6YsOxtV47DWJuOTEVgnbxP5gkmbc_HxLDOTEyG5Vvqe0rGPd92Od-zCqH1o6B-RhpCBn6zIyjjIQSWoOkoKjwrV4Y8xkCV7oPQf4HjVX/s640/GetCustomerContact+Dynamic.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<b>SQL:</b></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: black; color: white;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;">var sql = @"SELECT js.*</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"> FROM Customer c</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"> CROSS APPLY OPENJSON(c.[CustomerContacts], '$') WITH (</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> Id uniqueidentifier</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,Title VARCHAR(10)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,FirstName VARCHAR(50)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,MiddleName VARCHAR(50)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,LastName VARCHAR(50)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,CompanyName VARCHAR(50)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,SalesPerson VARCHAR(100)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,EmailAddress VARCHAR(100)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ,Phone VARCHAR(20)</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"><span style="white-space: pre;"> </span> ) AS js</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: black; color: white;"> WHERE c.id = @CustomerId";</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
You have to Cross apply with OPENJSON on JSON column WIth all columns with datatype and length. Column name should be matched with JSON properties including case.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
OPENJSON explained technically here in detail:</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-2017">https://docs.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-2017</a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivNvbh1ALk802bm5Oxv8Dw5qJz0pd6OmB3QFJuAP1g1KxgDNYpJZg-pONtprSgQWny8Z1DBQomkcVA7n6B71CLkfnnhC-rj3Yi1XC_8mVxlrrpFM9pgr7GN7nQofkmijf-Na87ahPygqA8/s1600/GetCustomerContact-Postman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="651" data-original-width="500" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivNvbh1ALk802bm5Oxv8Dw5qJz0pd6OmB3QFJuAP1g1KxgDNYpJZg-pONtprSgQWny8Z1DBQomkcVA7n6B71CLkfnnhC-rj3Yi1XC_8mVxlrrpFM9pgr7GN7nQofkmijf-Na87ahPygqA8/s640/GetCustomerContact-Postman.png" width="490" /></a></div>
<br />
<br />
JSON result set looks like above when getting each property individually.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs9HQenICpF4FC71Ct7C4d_JMMyKV9-B4e8h4EcCKaBnnO279BAxzCJnEJsY5lrvUQHQL9BI0LZ8SsmQme8cKo9-ejA5bThQ-ODJMt2xT2dBNrSRwwUOBTpmRW06gqfAwEAw9I4ZVqrgpG/s1600/Gets+CustomerContacts+Dynamically.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="277" data-original-width="1600" height="110" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs9HQenICpF4FC71Ct7C4d_JMMyKV9-B4e8h4EcCKaBnnO279BAxzCJnEJsY5lrvUQHQL9BI0LZ8SsmQme8cKo9-ejA5bThQ-ODJMt2xT2dBNrSRwwUOBTpmRW06gqfAwEAw9I4ZVqrgpG/s640/Gets+CustomerContacts+Dynamically.png" width="640" /></a></div>
<br />
<br />
If you don't want to use individual properties and may have dynamic schemaless properties then you can use OPENJSON() function without With.<br />
<br />
<h4 style="text-align: left;">
<b>Advantages:</b></h4>
1. Easy storage for Object graph in a single table.<br />
2. Easy to add a schemaless column in SQL server and having NoSql DB features for a smaller portion of an application. No need to switch database.<br />
3. Easy to get records and insert record as JSON and as fixed schema model or dynamic model.<br />
<br />
<h4 style="text-align: left;">
<b>Disadvantage.</b></h4>
1. This feature can not completely replace the NoSql database.<br />
2. If dynamic fields have to rely on schema from UI then it is not good for security reasons.<br />
3. It doesn't have good support of function when you wanted to add a new field in a fixed schema JSON array.<br />
4. In case if you have added big JSON array for a row then it may be a risk of information loss on by mistake edit by user and dba. Its a really good idea to add a temporal table feature to keep all the history of the table in this particular case.<br />
<br />
In case you have a column with an array of JSON and you wanted to add one field of each object of an array then you have to do either string operation or can do approach explained by me on following <a href="https://stackoverflow.com/questions/49828897/update-an-existing-json-value-inside-a-json-array-in-sql" target="_blank">StackOverflow </a>response given by me.<br />
<br />
<b>Example Code: </b><br />
<a href="https://github.com/atulpatel/SQL_Json" target="_blank">https://github.com/atulpatel/SQL_Json</a><br />
<br />
<b>Ref:</b><br />
<a href="https://stackoverflow.com/questions/49828897/update-an-existing-json-value-inside-a-json-array-in-sql" target="_blank">https://stackoverflow.com/questions/49828897/update-an-existing-json-value-inside-a-json-array-in-sql</a><br />
<a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/json-modify-transact-sql?view=sql-server-2017" target="_blank">https://docs.microsoft.com/en-us/sql/t-sql/functions/json-modify-transact-sql?view=sql-server-2017</a><br />
<a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/json-query-transact-sql?view=sql-server-2017" target="_blank">https://docs.microsoft.com/en-us/sql/t-sql/functions/json-query-transact-sql?view=sql-server-2017</a><br />
<div>
<a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-2017" target="_blank">https://docs.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-2017</a></div>
<br />
<b>Dapper:</b><br />
<div style="text-align: left;">
<a href="https://github.com/StackExchange/Dapper" target="_blank">https://github.com/StackExchange/Dapper</a></div>
<div style="text-align: left;">
<a href="https://dapper-tutorial.net/dapper" target="_blank">https://dapper-tutorial.net/dapper</a><br />
<br />
<b>Vertical slice Architecture:</b><br />
<a href="https://jimmybogard.com/vertical-slice-architecture/" target="_blank">https://jimmybogard.com/vertical-slice-architecture/</a></div>
</div>
</div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com1tag:blogger.com,1999:blog-3416772542415993289.post-37466561422216778372018-05-20T10:11:00.003-05:002018-05-20T10:11:47.365-05:00Customize UI design for multi tenant asp.net application using Bootstrap <div dir="ltr" style="text-align: left;" trbidi="on">
When you are developing a multitenant application, all your tenant (customer) wants their design or color coding (theme) different as per their brand. First, you have to come up with a unique design or layout of your web app which can be neutral and can be customizable to any different design easily. By reading this requirement, of course, you get Bootstrap in your mind. By using Bootstrap you can easily make your web app design very flexible and responsive. We all know benefits of using Bootstrap. If you don't then go to Getbootstrap.com and get it.<br />
<br />
Bootstrap can be base for responsive web applications. You need to do custom CSS by overriding existing bootstrap classes. You can also make your customization of bootstrap common for all tenant by using .less provided by bootstrap instead directly using .css.<br />
<br />
I have added my example of design multitenant web application design using bootstrap.<br />
<br />
For our implementation (our example), we considered bootstrap V3.3.7 as We still may have a learning curve of understanding of new version of the framework. We consider using new bootstrap is a little bit a risk for a team. You can use a new version of bootstrap and apply the same strategy for handling multiple tenants web design customization. We have used ASP.net MVC core project using visual studio.<br />
<br />
Implementation of custom design has done in following steps.<br />
<br />
<h3 style="text-align: left;">
1. Need to install basic bootstrap with .less files.</h3>
you can download bootstrap .less files from the following URL.<br />
<br />
<a href="https://getbootstrap.com/docs/3.3/getting-started/">https://getbootstrap.com/docs/3.3/getting-started/</a><br />
<br />
Also, you can implement packages like npm or nuget.<br />
<br />
It is also described here how to install grunt and grunt commands here<br />
<br />
https://getbootstrap.com/docs/3.3/getting-started/<br />
<br />
<h3 style="text-align: left;">
2. Define your own customization on top of bootstrap using your own .less files.</h3>
<div style="text-align: left;">
As per Asp.net core MVC project folder structure, I have added bootstrap .less file under lib/bootstrap.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYpl2CerGnaXUcHLeeqqCkYMjjfeSpNG2XOyOIK9ckfVAawB2P14uL2Ztt_C5Nl9MrJpoqeV8_sfQYvqgMFLwtc34rlt_upzlEH_rPRIbZ1mtTJl4b_w1KmBaqKMU27LlAHYgI5PlpAUI1/s1600/2018-05-08+22_41_11-WebApplication1+-+Microsoft+Visual+Studio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="768" data-original-width="429" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYpl2CerGnaXUcHLeeqqCkYMjjfeSpNG2XOyOIK9ckfVAawB2P14uL2Ztt_C5Nl9MrJpoqeV8_sfQYvqgMFLwtc34rlt_upzlEH_rPRIbZ1mtTJl4b_w1KmBaqKMU27LlAHYgI5PlpAUI1/s320/2018-05-08+22_41_11-WebApplication1+-+Microsoft+Visual+Studio.png" width="178" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
I have added a folder called "less" under the root folder. Added main.less file. This can be your application main .less file. You can add reference of bootstrap.less under this. The bootstrap.less file you can locate under lib/bootstrap/less. Bootstrap.less is the main file of bootstrap which has all reference to other bootstraps .less files and bootstrap variables. bootstrap.less looks like below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4KhJLfwJA8sZrYRjwKd00HfWPjJYXPP0ch1i0sbVhYetnUs8gFuq20_oQgMFtQvU6wh9udC2LGF8Wcq3hBvo1XS_bBdmBipnkYoB_7NLgSo64FkiLitxt_iYpeAFIb2ke66lt4vMWDd3f/s1600/2018-05-08+22_46_29-WebApplication1+-+Microsoft+Visual+Studio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="669" data-original-width="790" height="337" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4KhJLfwJA8sZrYRjwKd00HfWPjJYXPP0ch1i0sbVhYetnUs8gFuq20_oQgMFtQvU6wh9udC2LGF8Wcq3hBvo1XS_bBdmBipnkYoB_7NLgSo64FkiLitxt_iYpeAFIb2ke66lt4vMWDd3f/s400/2018-05-08+22_46_29-WebApplication1+-+Microsoft+Visual+Studio.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
main.less file has bootstrap.less reference.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRnan6FG4p4okvGc-Ii5bhee1ikjvXCj7JyhZW1oEj31wySk2fsGTpPGHCIKcncJJGOcTReJzJan9hmBHWE1J4kR6y-x3gawRlJd2qrCllt3-4qn6qO1LiPDx85arqSfvR-zIA1p6O5iVL/s1600/2018-05-08+22_48_29-WebApplication1+-+Microsoft+Visual+Studio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="529" data-original-width="819" height="257" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRnan6FG4p4okvGc-Ii5bhee1ikjvXCj7JyhZW1oEj31wySk2fsGTpPGHCIKcncJJGOcTReJzJan9hmBHWE1J4kR6y-x3gawRlJd2qrCllt3-4qn6qO1LiPDx85arqSfvR-zIA1p6O5iVL/s400/2018-05-08+22_48_29-WebApplication1+-+Microsoft+Visual+Studio.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
Check bootstrap variable.less file. Bootstrap has defined all variable for all colors and size. You can directly change this variable values. By Including bootstrap.less into main.less you can use these variables to your custom .css classes too. You can also override values variables if you wanted to keep your custom.less file separate for each tenant.<br />
<br /></div>
<h3 style="text-align: left;">
3. Install Grunt and packages for .less.</h3>
<div style="text-align: left;">
<span style="font-weight: normal;">You can use Gulp or Grunt as a task runner for generating .css file from .less files. You can do other tasks also like minification and bundling using it. For our example, we have used Grunt task runner. </span></div>
<div style="text-align: left;">
<span style="font-weight: normal;"><br /></span></div>
<div style="text-align: left;">
<span style="font-weight: normal;">You can find the detailed article about how to use Grunt with asp.net core <a href="https://docs.microsoft.com/en-us/aspnet/core/client-side/using-grunt?view=aspnetcore-2.1" target="_blank">here</a> and for Gulp <a href="https://docs.microsoft.com/en-us/aspnet/core/client-side/using-gulp?view=aspnetcore-2.1" target="_blank">here</a>.</span></div>
<div style="text-align: left;">
<a href="https://gruntjs.com/getting-started" target="_blank">here is the getting started with Grunt</a>.</div>
<div style="text-align: left;">
<br />
You need Nodejs installed on your machine. Install nodejs with Node Package Manager (npm).<br />
<br />
You can install Grunt using npm by the following command.<br />
<br />
<span style="background-color: #181818; color: #f8f8f8; font-family: "monaco" , "consolas" , "lucida console" , monospace; font-size: 14px; white-space: pre-wrap;">npm install -g grunt-cli</span></div>
<div style="text-align: left;">
<br />
For our project, we need to add npm Configuration File (package.json). </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiffuWRVofqc__MsPFWGRxFmVyAdCqisCMgfPnwLZHDIJGPME1Vxm_5FhDNpfWZKzr47jz5wug-49Ov7aofHjUW02rV72Fk7_hzWZuE_7fTF7d3vkxkRXZla_XF_LX3-KnUrhc-ukjFbGfk/s1600/2018-05-07+12_04_48-Clipboard.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="190" data-original-width="944" height="80" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiffuWRVofqc__MsPFWGRxFmVyAdCqisCMgfPnwLZHDIJGPME1Vxm_5FhDNpfWZKzr47jz5wug-49Ov7aofHjUW02rV72Fk7_hzWZuE_7fTF7d3vkxkRXZla_XF_LX3-KnUrhc-ukjFbGfk/s400/2018-05-07+12_04_48-Clipboard.png" width="400" /></a></div>
<h3 style="text-align: left;">
</h3>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
For manual install Grunt to your project Open a command prompt and change your directory to your project directory.</div>
<div>
<span style="font-family: "times" , "times new roman" , serif;"><br /></span></div>
<div>
<span style="background-color: black;"><span style="color: white; font-family: "times" , "times new roman" , serif;">cd c:\{your project directory}</span></span></div>
<div>
<br /></div>
<div>
If you have added nodejs to PATH environment variable then only has to apply npm command directly otherwise you have to give full path of npm exe like below and run install grunt.</div>
<div>
<br /></div>
<div>
<span style="background-color: white; font-family: "times" , "times new roman" , serif;"><br /></span></div>
<div>
<div>
<span style="background-color: black;"><span style="color: white; font-family: "times" , "times new roman" , serif;">C:\{your project directory}> "c:\Program Files\nodejs"\npm install grunt --save-dev</span></span></div>
<div>
<br /></div>
<div>
Install packages for .less</div>
<div>
<br /></div>
<div>
<div>
<span style="background-color: black; color: white; font-family: "times" , "times new roman" , serif;">C:\{your project directory}> "c:\Program Files\nodejs"\npm install grunt-contrib-less --save-dev</span></div>
<div>
<br /></div>
<div>
o/p: </div>
<div>
<i>+ grunt-contrib-less@1.4.1</i></div>
<div>
<i>added 62 packages in 8.574s</i></div>
</div>
<div>
<br /></div>
<div>
<b>Using visual studio</b>, You can simply update package.json file and update packages from Dependencies -> Righ click on "npm" => Click on "Restore packages"</div>
</div>
<div>
<br /></div>
<div>
"Package.json"</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKKX5CtqS5T66UvyzlkxByPtn2IIwDBTJxRiG-Mv9f1olpqWmI18iQXc4Fl8yBSxEdFUKtUAsI_Lb7o7_GKp0TWDcSSnticCM00zZ5Av8tvLt7Vok0kbOOfQUqMEi7-03QcfllVZ5hSe9Z/s1600/2018-05-07+12_25_20-AspCoreRnd+-+Microsoft+Visual+Studio++%2528Administrator%2529.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="327" data-original-width="405" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKKX5CtqS5T66UvyzlkxByPtn2IIwDBTJxRiG-Mv9f1olpqWmI18iQXc4Fl8yBSxEdFUKtUAsI_Lb7o7_GKp0TWDcSSnticCM00zZ5Av8tvLt7Vok0kbOOfQUqMEi7-03QcfllVZ5hSe9Z/s320/2018-05-07+12_25_20-AspCoreRnd+-+Microsoft+Visual+Studio++%2528Administrator%2529.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
"Restore Package"</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBmXsTS1SgYBKmRtFX5Dradp517Dcj5exexYuvpjev1FghWJhRETdoSCuX4g7mhX5ZdOyBfHYYwRHng_1BG6Keij81navwcOLp9i2f74sHrR8_sYSw0LRgBA3RoBfRRE8x8F3teYe6h2PV/s1600/2018-05-07+12_23_15-AspCoreRnd+-+Microsoft+Visual+Studio++%2528Administrator%2529.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="356" data-original-width="359" height="317" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBmXsTS1SgYBKmRtFX5Dradp517Dcj5exexYuvpjev1FghWJhRETdoSCuX4g7mhX5ZdOyBfHYYwRHng_1BG6Keij81navwcOLp9i2f74sHrR8_sYSw0LRgBA3RoBfRRE8x8F3teYe6h2PV/s320/2018-05-07+12_23_15-AspCoreRnd+-+Microsoft+Visual+Studio++%2528Administrator%2529.png" width="320" /></a></div>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<div>
It will look like following after restoring package<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMGNahwYOwFAENVGECfZAKzCJYV4nxi7PZB9jh81hpcmCtY_BK7sNAiZ6EKMIdo9rCNA-29-pdhjX6YFSw53aTj2H3SMFIPl4AhiGFiAkTUcvypWkdbSw8SbUpfv7d8SgiFfK0dA2xZuYl/s1600/2018-05-08+22_25_23-Clipboard.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="410" data-original-width="384" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMGNahwYOwFAENVGECfZAKzCJYV4nxi7PZB9jh81hpcmCtY_BK7sNAiZ6EKMIdo9rCNA-29-pdhjX6YFSw53aTj2H3SMFIPl4AhiGFiAkTUcvypWkdbSw8SbUpfv7d8SgiFfK0dA2xZuYl/s320/2018-05-08+22_25_23-Clipboard.png" width="299" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<h3 style="text-align: left;">
</h3>
<div>
Add Gruntfile.js to a solution. Get more information from here <a href="https://gruntjs.com/getting-started">https://gruntjs.com/getting-started</a><br />
<br />
sample grunt file looks like below.</div>
<div>
<span style="background-color: #181818; color: #f8f8f8; font-family: "monaco" , "consolas" , "lucida console" , monospace; font-size: 14px; white-space: pre-wrap;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4oIKXPQaykmp2Fw0uU7jnuARzdGeKOJomhvcjd4LlV9JSyJJF-AFwbgLITZGrewvU8BjGNiJZZ3EjOVYiP9w3N5XPZTDP-MCuHSlDapVHRahsehXQZ3v6R1IN37qDJRhzKOf5TrZXKzjx/s1600/2018-05-08+23_27_18-Getting+started+-+Grunt_+The+JavaScript+Task+Runner.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="361" data-original-width="914" height="157" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4oIKXPQaykmp2Fw0uU7jnuARzdGeKOJomhvcjd4LlV9JSyJJF-AFwbgLITZGrewvU8BjGNiJZZ3EjOVYiP9w3N5XPZTDP-MCuHSlDapVHRahsehXQZ3v6R1IN37qDJRhzKOf5TrZXKzjx/s400/2018-05-08+23_27_18-Getting+started+-+Grunt_+The+JavaScript+Task+Runner.png" width="400" /></a></div>
</div>
<h3 style="text-align: left;">
4. Generate different stylesheet files according to custom variables using Grunt.</h3>
<h3 style="text-align: left;">
</h3>
<div>
Using Grunt task runner you can generate .css file from .less file. We already have installed required package of .less.<br />
we need to add grunt task for .less with different parameter options. you can find the whole list of parameters and guideline of adding grunt task for less here. <a href="https://www.npmjs.com/package/grunt-contrib-less" target="_blank"> https://www.npmjs.com/package/grunt-contrib-less</a><br />
<br />
We are going to use "modifyVars" parameter to modify .less variable value. using this parameter, you can pass the value of any .less parameter like bootstrap @brand-primary.<br />
With "files" parameter you can define Source .less file and destination .css file (result file).<br />
<br />
In our case, we have our main.less file which has a reference of bootstrap.less along with custom CSS classes. We can define different task according to the environment. Also, we can define different task according to a tenant.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikZJAb9NM9HCYdTNlhI0SDFlzCLMCvrhK1sou73vs6oD42dkHnta9lISYjC5kUnD_qde3M_uXtWG5jg456aYQPRRjLD_6ln7joYbd2pHYTmCrS-pXFpec5-M54hndUNs95UpVsETas8IIt/s1600/2018-05-08+23_37_55-Clipboard.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="648" data-original-width="792" height="523" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikZJAb9NM9HCYdTNlhI0SDFlzCLMCvrhK1sou73vs6oD42dkHnta9lISYjC5kUnD_qde3M_uXtWG5jg456aYQPRRjLD_6ln7joYbd2pHYTmCrS-pXFpec5-M54hndUNs95UpVsETas8IIt/s640/2018-05-08+23_37_55-Clipboard.png" width="640" /></a></div>
<br />
<br />
Like above gruntfile, we have defined the task to generate CSS for the development environment and production environment.<br />
For development, you need to check .css classes sometimes so no need to do compression. while production environment you can define compress: true. It minifies the .css.<br />
We defined the value of 'brand-primary' variable under modifyVars for both environments.<br />
<br />
Under the "files" tag, You can define source file as .less file and result file .css file like in above example we have following.<br />
<br />
files: { 'wwwroot/css/site.debug.css': 'wwwroot/less/main.less'}<br />
<br />
Grunt task generates site.debug.css file in defined path using main.less file.<br />
<br />
Similar way you can add another task for a different tenant. you can pass variable value according to customer requirement. You can also generate different variable. less file with customer specific values and generate .css using different .less files according to tenants.<br />
Tenant task is shown below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiByPwaoKPXl8zs4eL_7QXb3O5_IOejZWX2Q_qmXbVXmgykb0-DOiqeJbHlvROfW6iePpZy1BS6S2JaP7h72z6U3ofo6XS95vb0NC2RLY_z3WBABkeUnSvpHuA9LQMbBwKInzu0rMoa7uUx/s1600/2018-05-08+23_46_54-WebApplication1+-+Microsoft+Visual+Studio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="664" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiByPwaoKPXl8zs4eL_7QXb3O5_IOejZWX2Q_qmXbVXmgykb0-DOiqeJbHlvROfW6iePpZy1BS6S2JaP7h72z6U3ofo6XS95vb0NC2RLY_z3WBABkeUnSvpHuA9LQMbBwKInzu0rMoa7uUx/s640/2018-05-08+23_46_54-WebApplication1+-+Microsoft+Visual+Studio.png" width="640" /></a></div>
<br />
<br /></div>
<h3 style="text-align: left;">
5. Add tenant code switch.</h3>
<div style="text-align: left;">
You can change the use of .css file according to your tenant id. You can manage it by _layout.cshtml.<br />
After login, you can get tenant name programmatically. You can implement base controller and take one global variable which can be used for all views. I would let you decide how would you get your tenant name as I wanted to focus on switching stylesheet according to different tenant name.<br />
<br />
In following code sample, I have created one variable called tenantcode which has tenant name. This variable can get value dynamically from server login according to who is logged. I have used tenantcode to generate CSS name for that particular tenant.<br />
<br />
In Asp.net MVC core, You can define the environment for development and production. You also can define your custom one. You can get more info about environment tag from this <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/environment-tag-helper?view=aspnetcore-2.1" target="_blank">URL</a>: <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/environment-tag-helper?view=aspnetcore-2.1">https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/environment-tag-helper?view=aspnetcore-2.1</a><br />
<br />
So as per our logic, it generates tenant CSS URL like "~/css/site_tenant1.css". It would be just site_.debug.css for development.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4lsPTL8w3ubjqpGmxQ0fF_ltkVZ0mMBq7EbOAjBCdagu2F9iaI6HPO289TL6BiJIaYmOC4bJu0wsWaAUhDd5BsBMyRe_JTaqSM-8GyDGGc67F8Lx6xmEIumQ-zlYNGnof2ezh0RAK9IBc/s1600/2018-05-08+23_49_32-WebApplication1+-+Microsoft+Visual+Studio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="336" data-original-width="785" height="273" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4lsPTL8w3ubjqpGmxQ0fF_ltkVZ0mMBq7EbOAjBCdagu2F9iaI6HPO289TL6BiJIaYmOC4bJu0wsWaAUhDd5BsBMyRe_JTaqSM-8GyDGGc67F8Lx6xmEIumQ-zlYNGnof2ezh0RAK9IBc/s640/2018-05-08+23_49_32-WebApplication1+-+Microsoft+Visual+Studio.png" width="640" /></a></div>
<br />
By changing tenantcode, you can just change the theme of your application.<br />
<br />
Tenant1 theme<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvs0i04UG99057VvUr0ilAj1S3ECMHQ2dx6BKwswzgg-tnDE0GXswqBPgjceiKo9N1vk7f-eoNRjoRPAK0ncrG5AEDcfMmkVMsoyGLZrH-bY5WOfG8MW2c1dME-preHmPEmBoQdEWiqWwu/s1600/2018-05-12+15_14_23-Home+Page+-+MvcCoreLessCss.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="438" data-original-width="1600" height="174" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvs0i04UG99057VvUr0ilAj1S3ECMHQ2dx6BKwswzgg-tnDE0GXswqBPgjceiKo9N1vk7f-eoNRjoRPAK0ncrG5AEDcfMmkVMsoyGLZrH-bY5WOfG8MW2c1dME-preHmPEmBoQdEWiqWwu/s640/2018-05-12+15_14_23-Home+Page+-+MvcCoreLessCss.png" width="640" /></a></div>
Development theme<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqVJxrwB_3wpi9wbWoMjUZtaeqCQmatKM6UqfufxyqAo7CPCsg-uwnw1LKCfxPEC8TEFVi0rq7UF-gCYdHVnPo2GdRpTe8DcGHQv8f-u8ezCh2jlSvbcGX3HSs3mIGvY40pM0acAipM92x/s1600/2018-05-12+15_14_58-Home+Page+-+MvcCoreLessCss.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="406" data-original-width="1600" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqVJxrwB_3wpi9wbWoMjUZtaeqCQmatKM6UqfufxyqAo7CPCsg-uwnw1LKCfxPEC8TEFVi0rq7UF-gCYdHVnPo2GdRpTe8DcGHQv8f-u8ezCh2jlSvbcGX3HSs3mIGvY40pM0acAipM92x/s640/2018-05-12+15_14_58-Home+Page+-+MvcCoreLessCss.png" width="640" /></a></div>
<br />
The code sample is here <a href="https://github.com/atulpatel/MvcCoreLessCss">https://github.com/atulpatel/MvcCoreLessCss</a>.<br />
<br />
If you want anything to elaborate more then let me know in the comment.<br />
<br /></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com9tag:blogger.com,1999:blog-3416772542415993289.post-65752914513646985452018-05-11T10:44:00.002-05:002018-05-11T10:44:29.673-05:00How to close your code<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
We all know them SOLID principles. Every developer knows what are SOLID principles because every developer has to go through an interview process to get a job. Some can explain really good while interview.<br />
<br />
Recently, I have been interviewed by a very reputed financial company. They have 4 rounds of interview and almost 3 round has asked a question about SOLID principles. They all have asked very good interesting questions and it seems they were looking for some specific expertise. I have started working there and their code base is awesome. They are not working anywhere near what they asked in an interview. I also found some controllers code files has 2-3k lines of code which is a presentation layer. Though they have very nice onion architecture for the project. I hope whoever worked there all gone through those interview process and know about at least SOLID principles. These principles are not just to perform in the interview. We need to apply it in real code. Maybe they have their own reasons for not following them.<br />
<br />
Anyway, here I wanted to show some example which I saw in their code base which can very easily make it closed for modification.<br />
<br />
Check following code.<br />
<br />
<div style="background: black; color: white; width: 100%;">
<code>
</code><br />
<code> public void Work(string switchoption)<br />
{<br />
switch (switchoption)<br />
{<br />
case "Fun1":<br />
///<br />
/// So many lines of code<br />
///<br />
break;<br />
case "Fun2":<br />
///<br />
/// So many lines of code<br />
///<br />
break;<br />
case "Fun3":<br />
///<br />
/// So many lines of code<br />
///<br />
break;<br />
}<br />
}<br />
</code>
<br />
<code><br /></code></div>
<br />
If you come across this kind of code or you may end up writing this kind of code then what can be at least done, I have explained it here. Above code is not closed because you don't know what kind of another case may have to add in future. What if there is a change in code for a particular switch case. You have to test all cases because you have changed it the function. If your unit test covered all switch cases then you are a little bit good position. QA has to check every case manually. If something missed in testing then you may end up in production bugs. Overall all these increases the maintenance cost.<br />
<br />
I do refactor it to the following levels.<br />
<br />
<h4 style="text-align: left;">
At least have a private function for long lines of code for each case.</h4>
<br />
<div style="background: black; width: 100%;">
<div style="color: white;">
<code><br /></code> <code>
public void Work(string switchoption)<br />
{<br />
switch (switchoption)<br />
{<br />
case "Fun1":<br />
function1();<br />
break;<br />
case "Fun2":<br />
function2();<br />
break;<br />
case "Fun3":<br />
function3();<br />
break;<br />
}<br />
}<br />
</code>
</div>
<div style="color: white;">
<br /></div>
<span style="color: white;"> private void function3()</span><br />
<span style="color: white;"> {</span><br />
<span style="color: white;"> Console.WriteLine("Function 3");</span><br />
<span style="color: white;"> }</span><br />
<span style="color: white;"><br /></span> <span style="color: white;"> private void function2()</span><br />
<span style="color: white;"> {</span><br />
<span style="color: white;"> Console.WriteLine("Function 2");</span><br />
<span style="color: white;"> }</span><br />
<span style="color: white;"><br /></span> <span style="color: white;"> private void function1()</span><br />
<span style="color: white;"> {</span><br />
<span style="color: white;"> Console.WriteLine("Function 1");</span><br />
<span style="color: white;"> }</span><br />
<span style="color: white;"><br /></span></div>
<br />
<br />
If you create private function then the code will at least increase readability. By giving a proper name to function, it describes that what that piece of code is doing. But still, it has an issue of what if we may need to write more cases there. This code is still not a closed code.<br />
<br />
<b>Instead of Switch case, you can implement Dictionary.</b><br />
<br />
<div style="background: black; color: white; width: 100%;">
<code> </code><br />
<code> public void Work2(string switchoption)<br />
{<br />
Dictionary<string, Action> switchfunction = new Dictionary<string, Action>();<br />
switchfunction.Add("Fun1", function1);<br />
switchfunction.Add("Fun2", function2);<br />
switchfunction.Add("Fun3", function3);<br />
<br />
switchfunction[switchoption].Invoke();<br />
}<br />
<br />
</code>
</div>
<br />
You can simply add a dictionary with string and Action type. Add all functions to dictionary collection. Dictionary can pick a particular case by Key name and execute the function by invoking it. You can also generate this dictionary list from outside of this function or get dictionary values from any data store. In case in future, you may need to add more cases then you don't have to change this function. This way your existing function Work2 here in the example can be closed for modification.<br />
<br />
This implementation has resolved our problem of closing the function "Work" for modification. But we still have to add a new function to the class for adding new cases. It is also not following Single responsibility principle.<br />
<br />
<h3 style="text-align: left;">
Implement Strategy pattern using Dependency Injection</h3>
Basic strategy pattern implementation explained here. <a href="http://www.dofactory.com/net/strategy-design-pattern" target="_blank">http://www.dofactory.com/net/strategy-design-pattern</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivKafgpVL1dsUcizkDSK9jBPYG0-b7J8fEaeUswr4YqlUDAkmGJxNB45WsVfDelvscKq4nIafV_7bmZ0hVD-5Lj-BIVaTO66kaWIJ3Uha6wGbltZm7c9xZabW5jne9rqiKEfAkcnDaY6Dg/s1600/2018-05-10+09_11_48-Strategy+.NET+Design+Pattern+in+C%2523+and+VB+-+dofactory.com.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="222" data-original-width="581" height="243" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivKafgpVL1dsUcizkDSK9jBPYG0-b7J8fEaeUswr4YqlUDAkmGJxNB45WsVfDelvscKq4nIafV_7bmZ0hVD-5Lj-BIVaTO66kaWIJ3Uha6wGbltZm7c9xZabW5jne9rqiKEfAkcnDaY6Dg/s640/2018-05-10+09_11_48-Strategy+.NET+Design+Pattern+in+C%2523+and+VB+-+dofactory.com.png" width="640" /></a></div>
<br />
The basic concept of pattern defines an Interface with strategy and have the concrete classes with different strategies implementation. Based on your need you can create an object of particular strategy dynamically. google it for <a href="http://bfy.tw/I5JG" target="_blank"> "strategy design pattern" </a> and you will get plenty of examples.<br />
<br />
Here I wanted to show an example using dependency framework. In above-given URL of dofactory example of strategy pattern, has context class to create an object of different strategies. We can rely on dependency injection framework for that responsibility.<br />
<br />
In the following code, IExampleStrategy is an interface and has functionexample(). This interface implemented in three different ExampleStrategy classes. each class has different implementation of functionexample.<br />
<br />
<div style="background: black; width: 100%;">
<code style="color: white;">
<br /> </code><span style="color: white; font-family: monospace;"> public interface IExampleStrategy</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> void functionexample();</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> public class ExampleStrategy1 : IExampleStrategy</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> public void functionexample()</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> Console.WriteLine("</span><span style="color: white; font-family: monospace;">ExampleStrategy1</span><span style="color: white; font-family: monospace;">.functionexample() executed.");</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> public class ExampleStrategy2 : IExampleStrategy</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> public void functionexample()</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> Console.WriteLine("</span><span style="color: white; font-family: monospace;">ExampleStrategy2</span><span style="color: white; font-family: monospace;">.functionexample() executed.");</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> public class ExampleStrategy3 : IExampleStrategy</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> public void functionexample()</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> Console.WriteLine("</span><span style="color: white; font-family: monospace;">ExampleStrategy3</span><span style="color: white; font-family: monospace;">.functionexample() executed.");</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> }</span><br />
<div style="color: white;">
<code><br /></code></div>
</div>
<br />
<br />
Following is the context class where we instantiate the class based on strategy. In the following class, we have injected IUnityContainer. It resolves right Strategy class based on a parameter.<br />
The Work function is the function that we are changing to our main problem of removing switch cases. The first Work function can pass parameter and decide what strategy need to execute. The container can get a right concrete class based on a parameter passed. Instantiating an object is a responsibility of container based on a parameter.<br />
<br />
Another Work function also does the same thing but in some cases, the developer has to do things in a loop. The container can take care of creating an object and also can take care of lifetime of your object. So in case if you have to create the same object multiple times for our second work function then a container can reuse the same object created previously.<br />
<div style="background: black; width: 100%;">
<code style="color: white;"><br /></code> <code style="color: white;"> </code><span style="color: white; font-family: monospace;">public class CloseCodeExample2</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> private readonly IUnityContainer _container;</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> public CloseCodeExample2(IUnityContainer container)</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> _container = container;</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> public void Work(string switchcall)</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> var examplefunction= _container.Resolve<IExampleStrategy>(switchcall);</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> examplefunction.functionexample();</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> public void Work(List<string> switchcalls)</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> foreach (var item in switchcalls)</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> var examplefunction = _container.Resolve<IExampleStrategy>(item);</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> examplefunction.functionexample();</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"> </span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<div style="color: white;">
<code><br /></code></div>
</div>
<br />
<br />
<br />
Here is our Main function where we have defined our Unity container registration for an interface and its implementation.<br />
<br />
<div style="background: black; width: 100%;">
<code style="color: white;"> </code><span style="color: white; font-family: monospace;"> class Program</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> static void Main(string[] args)</span><br />
<span style="color: white; font-family: monospace;"> {</span><br />
<span style="color: white; font-family: monospace;"> CloseCodeExample codeExample = new CloseCodeExample();</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> codeExample.Work("Fun1");</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> codeExample.Work2("Fun2");</span><br />
<span style="color: white; font-family: monospace;"> codeExample.Work2("Fun3");</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> //Unity container registration.</span><br />
<span style="color: white; font-family: monospace;"> var container = new UnityContainer();</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> container.RegisterType<IExampleStrategy, ExampleStrategy1>("Fun1");</span><br />
<span style="color: white; font-family: monospace;"> container.RegisterType<IExampleStrategy, ExampleStrategy2>("Fun2");</span><br />
<span style="color: white; font-family: monospace;"> container.RegisterType<IExampleStrategy, ExampleStrategy3>("Fun3");</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> CloseCodeExample2 codeExample2 = new CloseCodeExample2(container);</span><br />
<span style="color: white; font-family: monospace;"> </span><br />
<span style="color: white; font-family: monospace;"> codeExample2.Work("Fun1");</span><br />
<span style="color: white; font-family: monospace;"> codeExample2.Work("Fun2");</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> Console.WriteLine("---------------------------------");</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> codeExample2.Work(new List<string>() { "Fun2", "Fun3", "Fun1" });</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> Console.ReadKey();</span><br />
<span style="color: white; font-family: monospace;"><br /></span> <span style="color: white; font-family: monospace;"> }</span><br />
<span style="color: white; font-family: monospace;"> }</span><br />
<div style="color: white;">
<code><br /></code></div>
</div>
<br />
<br />
Let's validate our two SOLID principles that we wanted to implement. In above code, If you want to add new case then you need to add another class which implements the same interface and just need to register for the container. We don't need to change function "Work" It is basically closed for modification. Also, by creating a separate class for each case, We have implemented single responsibility principle. If you implement Unit test then it would be a separate unit test for all classes. Easy to implement the unit test.<br />
<br />
Note: In above example, you still have to consider little bit defensive code, for example, what if no any class implementation available to unity config. It will throw an exception of "Unity.Exceptions.ResolutionFailedException". So you still have to take care of this kind of things.<br />
<br />
I hope you like it. If you have any query, add it to comments.<br />
<br />
You can find code sample of above code here at GitHub. <a href="https://github.com/atulpatel/AspCoreRnd">https://github.com/atulpatel/AspCoreRnd</a><br />
<br /></div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com14tag:blogger.com,1999:blog-3416772542415993289.post-26985478486544831412018-03-10T02:04:00.000-06:002018-05-01T10:08:17.013-05:00Importance of Messaging for Enterprise applications<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Communication happens between multiple applications using four major approaches.<br />
1. File Transfer.<br />
One application writes a file and another application reads it later. Applications need to agree on file location and name to exchange information.<br />
<br />
2. Shared Database<br />
Multiple application share information using a common database. This way application doesn't have to exchange information as it is a single source of data.<br />
<br />
3. Remote Procedure<br />
One application exposes some functionality remote so another application can access it remotely as a remote procedure call. This is real-time synchronous communication<br />
<br />
4. Messaging.<br />
One application publishes or sends a message to common message channel (Queue) and another application cand read or consume message from the message channel later. This application must agree on channel and Message format to do this asynchronous communication.<br />
<br />
<h4 style="text-align: left;">
<span style="font-weight: normal;">Challenges of communication between applications.</span></h4>
<b><br /></b> As a developer, while developing a software we are taking many assumptions.<br />
For example, If we are developing an application which has to run an individual machine then we assume that while running that application it will always get enough memory and CPU cycle. An application has never had to wait for any other resource etc.<br />
<br />
While developing a software system which has to run on the different machine for different part of the application, we assume that communication between two system is reliable. The network is efficient with good latency. TCP communication over network runs in a reliable manner.<br />
<br />
Applications rarely live in isolation. any application has to communicate with other application directly or indirectly. while working on this kind of distributed application, developers make a false assumption. This is called "Fallacies of distributed application"<br />
<br />
<h4 style="text-align: left;">
<span style="font-weight: normal;">Fallacies of distributed application</span></h4>
<a href="https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing">https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing</a><br />
<br />
<b>The network is reliable.</b><br />
There can be many problems with a network like a cable cut, switch power cut, network h/w failure, firewall issue etc. Also, there can be some security attack. Applications like e-commerce highly affected by this issues.<br />
As a developer, we need to consider that network is unreliable and we need to address that too.<br />
<br />
<b>Latency is zero.</b><br />
Latency is a how much time it takes for data to move from one place to another.<br />
We develop an application on a local machine and considering LAN latency or local machine latency and considering latency is zero. But when an application goes into production environment then the scenario is different and application results into slower in performance or transaction failure.<br />
Ajax and Async/await are patterns are little use in this scenario.<br />
<br />
<b>Bandwidth is infinite.</b><br />
Bandwidth is capacity of a network to transfer data (how much data can be transferred).<br />
Bandwidth is continuously improving the network nowadays. Sometimes when bandwidth is lower then network packet loss ratio is high.<br />
Considering bandwidth is not infinite, we should limit the size of information we send over the wire.<br />
Always test application in a production environment for this kind of reason.<br />
<br />
<b>The network is secure.</b><br />
The Network is far from secure.<br />
1. General Internet attack trends are showing a 64% annual rate of growth<br />
2. The average company experienced 32 attacks per week over the past 6 months<br />
3. Attacks during weekdays increased in the past 6 months" [RipTech].<br />
<br />
As a developer, we always think of security and awareness of all security and the implications. Sometimes provides message-level security for more confidential information considering network is unsecured.<br />
<br />
<b>Topology doesn't change.</b><br />
<b><br /></b> When we deploy an application on production environment its topology may change. on Network we have to change servers, load balancers, Active directory settings etc. Sometimes we change the whole vendor with different network architecture (AWS/Azure).<br />
The application should work in any of the topology change.<br />
<br />
The application should not depend on specific endpoints or routes. It should be always prepared for renegotiating endpoints or provide discovery services.<br />
Another strategy is to abstract the physical structure of the network. Instead of depending on specific IP address, the application should depend on DNS name.<br />
<br />
<b>There is one administrator.</b><br />
If we have an application subsystem which outside of your administrative control then it can be an issue for your application.<br />
We have integrated third-party pricing supplier API. Sometimes they change their security protocol and strategy without even informing us in advance. That results in failure of a part of our application. Sometimes they change data model also without informing in advance. Sometimes they let us know in advance about their change.<br />
This type of changes is not in control of one administrator. We should develop our application in a way that it can very less depend on their model structure. Also, we can provide two version of implementation. One can work with an older version and another for the new version so the application can decide automatically which one needs to use until it finals all the changes.<br />
<br />
<b>Transport cost is zero.</b><br />
When information transfer over the network it has to be serialized into bits. This conversion takes server resources and also add latency.<br />
Also, All networking instrument like the router, subnet, load balancer has its own cost. Some cloud providers also charge based on data transferred across applications.<br />
Developers normally ignore this costs. They should consider this aspect also and develop the cost-effective application.<br />
<br />
<b>The network is homogeneous.</b><br />
The network is not same everywhere. Even at home in the Similar network also may use different systems like Linux and windows. This can be an issue of data formate, protocols etc.<br />
The application should use a standard protocol like XML/JSON. The application should be used both according to client request it should respond in a particular format<br />
<br />
<br />
Messaging System can save some of the above scenarios.<br />
<br />
<h4 style="text-align: left;">
<span style="font-weight: normal;">What is a messaging system?</span></h4>
<br />
We can take an example of telephone voice mail system. One person calls to another person and leaves a voicemail. That voicemail queued to a message queue(mailbox). once person wanted to listen to voicemail, it dequeues a message from the queue.<br />
<br />
Messaging definition: Messaging is a technology that enables high-speed, asynchronous, a program to program communication with reliable delivery.<br />
<b><br /></b> <b>Applications</b> communicate by sending packets of data called Messages to each other.<br />
<b>Channels</b>(queues) are logical pathways that connect that program and convey a message.<br />
<b>Sender</b> or producer is an application that sends messages by writing the message to a channel. <b>Reciever</b> or Consumer is an application receives a message by reading from the channel.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipxZrKO00akefZ5vunpGnSqUhlzEmHkuNlc_wPHXJfeIwhLMQMhfRCmYkHkTkh7HYU2nSfQjHdDIArR5z6z2nOpIqzG33qK3Vq561jfpks8u6m46DNJDqf1QxJqQKUmolfTCr_Gm4WhiD0/s1600/Messaging+System+%25281%2529.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="311" data-original-width="771" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipxZrKO00akefZ5vunpGnSqUhlzEmHkuNlc_wPHXJfeIwhLMQMhfRCmYkHkTkh7HYU2nSfQjHdDIArR5z6z2nOpIqzG33qK3Vq561jfpks8u6m46DNJDqf1QxJqQKUmolfTCr_Gm4WhiD0/s640/Messaging+System+%25281%2529.png" width="640" /></a></div>
<br />
<br />
Messaging capability provided by separate software called Messaging system or Message Oriented Middleware (MOM). NServiceBus, MassTransit.<br />
<br />
Messaging system manages messages while send/publish a message to consume the message. It also uses a database to persists message and state. An administrator has to configure a messaging system with messaging channel that defines the path of communication between sender application and receiver application. The primary purpose of the messaging system to move messages from sender application to receiver application in a reliable fashion. While transmitting a message from sender to receiver, at any point, failure occurs then Messaging system retry to transmit until it succeeded.<br />
<br />
Message transmits in following steps:<br />
<br />
1. Create: sender creates a message using message model class and populates with data.<br />
2. Send: The sender add a message to the channel.<br />
3. Deliver: Message system moves the message from senders machine to receivers machine.<br />
4. Receive: The receiver reads the message from the channel.<br />
5. Process: Receiver extract data from the message.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwB2df8Q_IVJAJauKD_SmW3T2DXg-70zAnIa7_v7mscanPIUTXGZQvD2110eEZRtTMWE8263aYdJRPV5MGhH7Fvnzb2Cc4zvlvK03vGEzKggmI-PSK9iXoDCMd2zOo2cdpIVcDlJeMnjVF/s1600/2018-03-09+22_24_05-Clipboard.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="345" data-original-width="686" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwB2df8Q_IVJAJauKD_SmW3T2DXg-70zAnIa7_v7mscanPIUTXGZQvD2110eEZRtTMWE8263aYdJRPV5MGhH7Fvnzb2Cc4zvlvK03vGEzKggmI-PSK9iXoDCMd2zOo2cdpIVcDlJeMnjVF/s320/2018-03-09+22_24_05-Clipboard.png" width="320" /></a></div>
<br />
<br />
<h4 style="text-align: left;">
<span style="font-weight: normal;">Advantages of Messaging system</span></h4>
1. Remote Communication reliable<br />
Messaging enables separate applications to communicate and transfer data.<br />
<br />
2. Plateform / Language integration.<br />
Messages can be consumed by an application written in a different language and deployed on a different platform as it message formate is standard like XML or JSON.<br />
<br />
3. Asynchronous communication<br />
Messaging provides fire and forgets communication. The application doesn't need to wait until it finishes execution.<br />
<br />
3. variable timing:<br />
In synchronous communication, both applications have to wait for each other to complete a transaction.<br />
In messaging scenario, both applications can work on at their own pace. no one has to wait for each other.<br />
<br />
4. Throttling<br />
In an RPC application it is a single point of the receiver of requests and When there is too many requests comes to a single receiver then it may crash the application. In Messaging scenario it only accepts message from queue whenever it is ready.<br />
<br />
5. Reliable communication.<br />
Covering all fallacies, Messaging system uses to store and forward approach to transmitting messages. Sending system stores messages and receiver system also stores a message. Messaging system resends messages until it received by receiver successfully.<br />
<br />
6. Disconnect operation:<br />
Some applications are designed to work in a disconnected environment. Messages are queued. Whenever it connects to a network it can start consuming or sending messages.<br />
<br />
7. Mediation<br />
Messaging system can act as a mediator between two application.<br />
<br />
8. Thread management.<br />
By Asynchronous communication, Threads doesn't need to be blocked until other applications finish its work. Request/Response scenario also can be implemented by the messaging system.<br />
<br />
<h4 style="text-align: left;">
<span style="font-weight: normal;">Challenges of Messaging system</span></h4>
<b><br /></b> <b>Complex programming model</b><br />
Implementation of messaging system is little complex then RPC or another synchronous system. Debugging is complex. Requires little learning curve for new developers.<br />
<br />
<b>Sequence issues</b><br />
Messaging system guarantee message delivery but not in proper sequence. You need to take special care of it. Implement saga and correlation can resolve this issue.<br />
<br />
<b>Synchronous scenario</b><br />
In many cases, we need to provide instant feedback to the client about performed operation result.<br />
We need to implement request/response or Push notification to cover up this.<br />
<br />
<br />
Ref: Book: <a href="https://read.amazon.in/kp/embed?asin=B007MQLL4E&preview=newtab&linkCode=kpe&ref_=cm_sw_r_kb_dp_c44OAb48EE7Z1&tag=atulpatelmca-20">Enterprise-Integration-Patterns-Designing-Deploying</a><br />
<a href="https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing">https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing</a><br />
<a href="http://www.rgoarchitects.com/Files/fallacies.pdf">www.rgoarchitects.com/Files/fallacies.pdf</a><br />
<br /></div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com3tag:blogger.com,1999:blog-3416772542415993289.post-53948745145517191252017-04-01T23:56:00.001-05:002017-04-03T00:09:14.399-05:00Polling from angularJs ($interval)<div dir="ltr" style="text-align: left;" trbidi="on">
Recently come across the situation that we need to get status for one of disconnected service and show on browser. We end up doing polling from angular Js $interval service. We could have use SignalR features of asp.net for same thing but wanted to do it more simple way.<br />
<br />
We can do it polling easily using $interval service.<br />
here is detail document about $interval <a href="https://docs.angularjs.org/api/ng/service/$interval">https://docs.angularjs.org/api/ng/service/$interval</a><br />
<br />
<b>Problem</b> using $interval is that if you are doing $http service calling or server interaction and if server delayed response more than $interval time then before your one request completes, it starts another request. your next interval will be in race with previous response.<br />
<br />
<b>Solution:</b><br />
<br />
1. To avoid above problem, polling should be simple status getting from server like a single bit or very lightweight json so it should be complete within your defined interval time. You should also define time of interval appropriately to avoid this issue.<br />
<br />
2. If somehow it is still happening due to any reason, you should check a global flag that checks previous request finished or not before sending any other requests. It will miss that time interval but it won't send request prematurely.<br />
<br />
Meaning if you set $interval time as 1000 milliseconds and it sent first get request to server and that request didn't sent response yet before 1000 milliseconds and your second interval starts before completes previous one.<br />
<br />
Someone has resolve this issue using just $timeout service. <a href="https://blog.guya.net/2016/08/08/simple-server-polling-in-angularjs-done-right/" rel="nofollow" target="_blank">here</a> is the blog. This guy has used recursion to resolve this issue. meaning you can call same polling function from resulted promise. This is good but i believe that recursion saves function call stack. All browser has its one limit of stack. browser stack limit also depend on other factors like memory, open number of tabs etc.<br />
<br />
Someone has done very nice research on it.<br />
<br />
<a href="https://www.nczonline.net/blog/2009/05/19/javascript-stack-overflow-error/">https://www.nczonline.net/blog/2009/05/19/javascript-stack-overflow-error/</a><br />
<a href="https://web.archive.org/web/20110128022845/http://www.javascriptrules.com/2009/06/30/limitation-on-call-stacks/">https://web.archive.org/web/20110128022845/http://www.javascriptrules.com/2009/06/30/limitation-on-call-stacks/</a><br />
<br />
You can also perform some test using following url<br />
<a href="http://adamrich.name/recursion.html">http://adamrich.name/recursion.html</a><br />
<br />
Another <b>problem</b> with using $interval service is, We should stop interval after some threshold value because it may happens that server has some issue or error and it may never turn in to your desired result from server to stop your interval.<br />
<br />
Here is working example where you can use $interval solve both of above problems.<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'use
strict'</span><span style="font-family: "consolas"; font-size: 9.5pt;">;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;">angular.module(</span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'myApp.view2'</span><span style="font-family: "consolas"; font-size: 9.5pt;">, [</span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'ngRoute'</span><span style="font-family: "consolas"; font-size: 9.5pt;">])<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;">.controller(</span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'View2Ctrl'</span><span style="font-family: "consolas"; font-size: 9.5pt;">, [</span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'$scope'</span><span style="font-family: "consolas"; font-size: 9.5pt;">, </span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'$timeout'</span><span style="font-family: "consolas"; font-size: 9.5pt;">, </span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'$interval'</span><span style="font-family: "consolas"; font-size: 9.5pt;">, </span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'$http'</span><span style="font-family: "consolas"; font-size: 9.5pt;">, </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> ($scope, $timeout, $interval, $http) {</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $scope.title = </span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"Test Title"</span><span style="font-family: "consolas"; font-size: 9.5pt;">;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $scope.data = [];<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">var</span><span style="font-family: "consolas"; font-size: 9.5pt;"> hasvaluereturnd = </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">true</span><span style="font-family: "consolas"; font-size: 9.5pt;">; </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">// Flag to check </span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">var</span><span style="font-family: "consolas"; font-size: 9.5pt;"> thresholdvalue = 20; </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">// interval
threshold value</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> poll(interval, callback) {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="font-family: "consolas"; font-size: 9.5pt;"> $interval(</span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">if</span><span style="font-family: "consolas"; font-size: 9.5pt;"> (hasvaluereturnd) { </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">//check flag before start new call</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> callback(hasvaluereturnd);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> thresholdvalue = thresholdvalue
- 1; </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">//Decrease
threshold value </span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">if</span><span style="font-family: "consolas"; font-size: 9.5pt;"> (thresholdvalue == 0) {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $scope.stopPoll(); </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">// Stop $interval if it reaches to threshold</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }, interval)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">var</span><span style="font-family: "consolas"; font-size: 9.5pt;"> pollpromise = poll(1000, </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> hasvaluereturnd = </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">false</span><span style="font-family: "consolas"; font-size: 9.5pt;">;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">//$timeout(function
() { // You can test scenario where
server </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: "consolas"; font-size: 9.5pt;"> takes more time then interval</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $http.get(</span><span style="color: #a31515; font-family: "consolas"; font-size: 9.5pt;">'http://httpbin.org/get?timeoutKey=timeoutValue'</span><span style="font-family: "consolas"; font-size: 9.5pt;">).then(<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> (data) {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> hasvaluereturnd = </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">true</span><span style="font-family: "consolas"; font-size: 9.5pt;">;
</span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">// set Flag to true to start new call</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $scope.data = data;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> },<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> (e) {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> hasvaluereturnd = </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">true</span><span style="font-family: "consolas"; font-size: 9.5pt;">; </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">// set
Flag to true to start new call</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">//You can set false also as per your requirement in case of error</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> );<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">//}, 2000); </span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">// stop
interval.</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $scope.stopPoll = </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">function</span><span style="font-family: "consolas"; font-size: 9.5pt;"> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> $interval.cancel(pollpromise);<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> thresholdvalue = 0; </span><span style="color: green; font-family: "consolas"; font-size: 9.5pt;">//reset all
flags. </span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> hasvaluereturnd = </span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">true</span><span style="font-family: "consolas"; font-size: 9.5pt;">;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<span style="font-family: "consolas"; font-size: 9.5pt; line-height: 107%;"> }]);</span><o:p></o:p><br />
<span style="font-family: "consolas"; font-size: 9.5pt; line-height: 107%;"><br /></span>
<span style="font-family: "consolas"; font-size: 9.5pt; line-height: 107%;">Reference:</span><br />
<span style="font-family: "consolas"; font-size: 9.5pt; line-height: 107%;"><br /></span>
<span style="font-family: "consolas"; font-size: 9.5pt; line-height: 107%;"><span style="font-family: "times new roman"; font-size: small;">Above code just wrote on angular js seed boilerplate code for angularjs 1.x. Github location is <a href="https://github.com/angular/angular-seed" target="_blank">here</a></span></span><br />
Also, we have used <a href="http://httpbin.org/">http://httpbin.org/</a> for any third party test call. Which is very nice to test all http library. you can send any type of request and get response.<br />
<br /></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com5tag:blogger.com,1999:blog-3416772542415993289.post-86797917614409688362014-07-11T11:21:00.001-05:002014-07-11T11:21:16.007-05:00Session Helper<div dir="ltr" style="text-align: left;" trbidi="on">
I am writing this for my own repository of using session variables and though may be useful to others friends also. Over use of session variables are not good. Try to avoid using it. It takes server memory. If you want to use it then this code example shows how to use it without worrying to remember Session keys and simply access like a property with appropriate type.<div>
<br /></div>
<div>
I am explaining everything using code and code comments. </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<pre style="background: rgb(30, 30, 30); color: gainsboro; font-family: Consolas; font-size: 13px;"><span style="color: #57a64a;">///</span><span style="color: #57a64a;"> Session Helper class</span>
<span style="color: #569cd6;">public</span> <span style="color: #569cd6;">static</span> <span style="color: #569cd6;">class</span> SessionHelper
{
<span style="color: #57a64a;">///</span><span style="color: #57a64a;"> The userinfo Key</span>
<span style="color: #569cd6;">const</span> <span style="color: #569cd6;">string</span> USERINFO <span style="color: #b4b4b4;">=</span> <span style="color: #d69d85;">"USERINFO"</span>;
<span style="color: #57a64a;">///</span><span style="color: #57a64a;"> The userclaiminfo Key</span>
<span style="color: #569cd6;">const</span> <span style="color: #569cd6;">string</span> USERCLAIMINFO <span style="color: #b4b4b4;">=</span> <span style="color: #d69d85;">"USERCLAIMINFO"</span>;
<span style="color: #57a64a;">///</span><span style="color: #57a64a;"> Property to Get or sets the user claim information from or to Session.</span>
<span style="color: #569cd6;">public</span> <span style="color: #569cd6;">static</span> <span style="color: #4ec9b0;">UserClaimsInfo</span> UserClaimInfo
{
<span style="color: #569cd6;">get</span>
{
<span style="color: #569cd6;">return</span> GetInfoFromSession<span style="color: #b4b4b4;"><</span><span style="color: #4ec9b0;">UserClaimsInfo</span><span style="color: #b4b4b4;">></span>(USERCLAIMINFO);
}
<span style="color: #569cd6;">set</span>{
SetInforToSession<span style="color: #b4b4b4;"><</span><span style="color: #4ec9b0;">UserClaimsInfo</span><span style="color: #b4b4b4;">></span>(<span style="color: #569cd6;">value</span>, USERCLAIMINFO);
}
}
<span style="color: #57a64a;">///</span><span style="color: #57a64a;"> Property to Get or set the user information from or to session.</span>
<span style="color: #569cd6;">public</span> <span style="color: #569cd6;">static</span> <span style="color: #4ec9b0;">Userinfo</span> UserInfo
{
<span style="color: #569cd6;">get</span>
{
<span style="color: #569cd6;">return</span> GetInfoFromSession<span style="color: #b4b4b4;"><</span><span style="color: #4ec9b0;">Userinfo</span><span style="color: #b4b4b4;">></span>(USERINFO);
}
<span style="color: #569cd6;">set</span>{
SetInforToSession<span style="color: #b4b4b4;"><</span><span style="color: #4ec9b0;">Userinfo</span><span style="color: #b4b4b4;">></span>(<span style="color: #569cd6;">value</span>, USERINFO);
}
}
<span style="color: #57a64a;">///</span><span style="color: #57a64a;"> Priavate generic method to Get information from session using Key.</span>
<span style="color: #569cd6;">private</span> <span style="color: #569cd6;">static</span> T GetInfoFromSession<span style="color: #b4b4b4;"><</span>T<span style="color: #b4b4b4;">></span>(<span style="color: #569cd6;">string</span> key)
{
<span style="color: #569cd6;">if</span> (<span style="color: #4ec9b0;">HttpContext</span><span style="color: #b4b4b4;">.</span>Current<span style="color: #b4b4b4;">.</span>Session[key] <span style="color: #b4b4b4;">!=</span> <span style="color: #569cd6;">null</span> <span style="color: #b4b4b4;">&&</span> <span style="color: #4ec9b0;">HttpContext</span><span style="color: #b4b4b4;">.</span>Current<span style="color: #b4b4b4;">.</span>Session[key] <span style="color: #569cd6;">is</span> T)
{
<span style="color: #569cd6;">return</span> (T) <span style="color: #4ec9b0;">HttpContext</span><span style="color: #b4b4b4;">.</span>Current<span style="color: #b4b4b4;">.</span>Session[key];
}
<span style="color: #569cd6;">return</span> <span style="color: #569cd6;">default</span>(T);
}
<span style="color: #57a64a;">///</span><span style="color: #57a64a;"> Priavate method to set information to session using Key.</span>
<span style="color: #569cd6;">private</span> <span style="color: #569cd6;">static</span> <span style="color: #569cd6;">void</span> SetInforToSession<span style="color: #b4b4b4;"><</span>T<span style="color: #b4b4b4;">></span>(T info, <span style="color: #569cd6;">string</span> key)
{
<span style="color: #4ec9b0;">HttpContext</span><span style="color: #b4b4b4;">.</span>Current<span style="color: #b4b4b4;">.</span>Session[key] <span style="color: #b4b4b4;">=</span> info;
}
}</pre>
</div>
<div>
<br /></div>
<div>
In above code block You can add individual property for each session variable. You can to define constant variable for defining key. Session variable property can use generic method GetInfoFromSession<T> and SetInfoToSession<T> to get and set values to and from session. </div>
<div>
<br /></div>
<div>
Thanks.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com0tag:blogger.com,1999:blog-3416772542415993289.post-17017293641721829622014-02-13T15:12:00.003-06:002014-02-18T09:06:59.741-06:00Code snippet search<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">Code snippet search is going to be very easy now and in future with our favorite IDE like visual studio.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">It is using Microsoft Bing. </span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Bing searches code from coding community like </span><br />
<br />
<ul style="text-align: left;">
<li><span style="font-family: Verdana, sans-serif;"> MSDN</span></li>
<li><span style="font-family: Verdana, sans-serif;"> StackOverFlow</span></li>
<li><span style="font-family: Verdana, sans-serif;"> Dotnetperls</span></li>
<li><span style="font-family: Verdana, sans-serif;"> CSharp411</span></li>
</ul>
<br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<br />
<span style="font-family: Verdana, sans-serif;">To search a code snippet, You can go to following Url.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><a href="http://codesnippet.research.microsoft.com/">http://codesnippet.research.microsoft.com/</a></span><br />
<br />
<span style="font-family: Verdana, sans-serif;">It is looking like this.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRk3-vzu7gLL5RWu9_dojlD0Hq9VXKpPnIHNpcZ6cfuhANJbns3eb_oR9plHwtLKusCG0Q-wmfTy9JNFI4SHxyLVXsbz6qgEx2LGJ8p3x2e9-OUVECxdBJgkpwO6PuhLjJ4bWfNJ_ZKjsD/s1600/Bing+Code+Search+for+C%23+in+Visual+Studio+-+Google+Chrome_2014-02-13_14-39-40.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRk3-vzu7gLL5RWu9_dojlD0Hq9VXKpPnIHNpcZ6cfuhANJbns3eb_oR9plHwtLKusCG0Q-wmfTy9JNFI4SHxyLVXsbz6qgEx2LGJ8p3x2e9-OUVECxdBJgkpwO6PuhLjJ4bWfNJ_ZKjsD/s1600/Bing+Code+Search+for+C%23+in+Visual+Studio+-+Google+Chrome_2014-02-13_14-39-40.png" height="291" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">All instruction is written there like how to get code snippet.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">Start with special comment<b> "///".</b></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">Then you just need to type your code snippet query in English like you search in Google. and press Tab will show you intellisense like window. which also show code in next window beside the main window.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">You can select and get the code snippet. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbm6nIwspQbApMhyphenhyphenTWb1lYITjJ6zprNkXDp8hn4Nctjef0R93FJhh4VdJpRGNwcIpuz6Nz258Jc8BPTqUhz1b4chvNVA8bf1eZ5RLVjh-GjJrsJbHNhwibt9dQ-GrvBx3bIPrlgpMV-W0J/s1600/Bing+Code+Search+for+C%23+in+Visual+Studio+-+Google+Chrome_2014-02-13_14-47-46.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbm6nIwspQbApMhyphenhyphenTWb1lYITjJ6zprNkXDp8hn4Nctjef0R93FJhh4VdJpRGNwcIpuz6Nz258Jc8BPTqUhz1b4chvNVA8bf1eZ5RLVjh-GjJrsJbHNhwibt9dQ-GrvBx3bIPrlgpMV-W0J/s1600/Bing+Code+Search+for+C%23+in+Visual+Studio+-+Google+Chrome_2014-02-13_14-47-46.png" height="432" width="640" /></span></a></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">You can select and get the code snippet. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">You can also do directly from Visual Studio directly. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">You can download VS extension from <a href="http://visualstudiogallery.msdn.microsoft.com/a1166718-a2d9-4a48-a5fd-504ff4ad1b65" target="_blank">here</a>. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">Check this blog for more </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">detail <a href="http://blogs.msdn.com/b/visualstudio/archive/2014/02/17/introducing-bing-code-search-for-c.aspx" target="_blank">http://blogs.msdn.com/b/visualstudio/archive/2014/02/17/introducing-bing-code-search-for-c.aspx</a></span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">Who want to remember all the code all the time. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">There are some other websites also there for code snippet repository</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">Like </span></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<ul style="text-align: left;">
<li><a href="http://snipplr.com/" target="_blank"><span style="font-family: Verdana, sans-serif;">http://snipplr.com/</span></a></li>
<li><span style="font-family: Verdana, sans-serif;"><a href="http://css-tricks.com/snippets/" target="_blank">http://css-tricks.com/snippets</a> for CSS.</span></li>
</ul>
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: Verdana, sans-serif;">Happy Coding....</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com1tag:blogger.com,1999:blog-3416772542415993289.post-10780270571577448752014-01-11T15:18:00.001-06:002014-01-14T22:22:22.346-06:00TFS with VS 2013 tutorial <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Microsoft has provided online Visual studio support for Team Foundation Server and Git. <br />
You can create your visual studio account and access your own TFS. You can use your own code repository online anytime anywhere. It is free for up to 5 Users.<br />
<br />
Go to following url : <a href="http://www.visualstudio.com/" rel="nofollow" target="_blank">http://www.visualstudio.com/</a><br />
<br />
Click on "<span style="background-color: lime;">Get Started for free" </span>highlighted in green background.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhikSanRXvNFihUBJ5hObshwhMY1pK61TglKE3o8Sn0er0Mi2tBohLG_vF-l3P-VLA1cIcQ2UEssxB2uVgYfePopRu47cP4PBtgjsiMszbCPeFLutAsqFKKmH9nJDFnvddxjdu22x0yjkOw/s1600/Image+2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="Visual Studio" border="1px" height="347" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhikSanRXvNFihUBJ5hObshwhMY1pK61TglKE3o8Sn0er0Mi2tBohLG_vF-l3P-VLA1cIcQ2UEssxB2uVgYfePopRu47cP4PBtgjsiMszbCPeFLutAsqFKKmH9nJDFnvddxjdu22x0yjkOw/s1600/Image+2.png" style="border-color: black;" title="VisualStudio.com" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Sign in using your any windows live account user id/ password. If you don't have windows live id then you can create one by clicking "<span style="color: #0b5394;">Sign up now</span>".</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieOtd0Y0wIKe8LXSUI0Zd-s4zpb_C3GNNm9X7vYiUnHmHQJCySAofOuagumamL4m-NshckWroZl0eSuuJf4XyNBvpIT2mhcJa7WYy0Js2gBEL36Z9oMnylIf_OJDZH-4swj3H6oVP3psps/s1600/Image+6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieOtd0Y0wIKe8LXSUI0Zd-s4zpb_C3GNNm9X7vYiUnHmHQJCySAofOuagumamL4m-NshckWroZl0eSuuJf4XyNBvpIT2mhcJa7WYy0Js2gBEL36Z9oMnylIf_OJDZH-4swj3H6oVP3psps/s1600/Image+6.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After login, You will get this page. You will find your name as logged in User. If you want to use Visual studio 2013 trial version then you can download from here. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdjCij5TmF8EC1PJd8Jm322NDH4MI1S6P5jtXBIZ9bl1omS46ag_sUO1ZrspT8T8hFkhsO1gqCCAT0dKnUUTqmmb3kK2P4fFgTjaio_Qeug6HW9zWumZzq_aNsnxzloII1bwXwaQOaQK0q/s1600/Image+9.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdjCij5TmF8EC1PJd8Jm322NDH4MI1S6P5jtXBIZ9bl1omS46ag_sUO1ZrspT8T8hFkhsO1gqCCAT0dKnUUTqmmb3kK2P4fFgTjaio_Qeug6HW9zWumZzq_aNsnxzloII1bwXwaQOaQK0q/s1600/Image+9.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Click on your user name and you will get following page.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH9ll55i8Ee2uX9K3pgr-5kwoQu6p_aa1JcmSzcc94Jjf0_7R4umW2aZjc3NJeQBpQ-7F9vfGlE97UWZ310B1FMeHxOnboKdx_lvTPGeUxMQbxqL7Xs01-CMzOZPSt1iO_GTe7yTqPiylg/s1600/Image+12.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH9ll55i8Ee2uX9K3pgr-5kwoQu6p_aa1JcmSzcc94Jjf0_7R4umW2aZjc3NJeQBpQ-7F9vfGlE97UWZ310B1FMeHxOnboKdx_lvTPGeUxMQbxqL7Xs01-CMzOZPSt1iO_GTe7yTqPiylg/s1600/Image+12.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
You can find URL starts with your username like {your username}.visualstudio.com. It is your online TFS access link. click on that link. You can add up to 5 Users for free.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinzL6igbHE8P-qkwZa-Dc0n1q_aaxW7LdoiUTpcSLnB4MpgH1HDSDrinH2beQMpJ9RQ9L03pCzwBO-lfT68uqOYYG1Tl6bUnryk-hNKDEuHTf-XciQ4mDtwWEwaS5r-Xm-SlSrpu_KerMh/s1600/Image+14.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="306" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinzL6igbHE8P-qkwZa-Dc0n1q_aaxW7LdoiUTpcSLnB4MpgH1HDSDrinH2beQMpJ9RQ9L03pCzwBO-lfT68uqOYYG1Tl6bUnryk-hNKDEuHTf-XciQ4mDtwWEwaS5r-Xm-SlSrpu_KerMh/s1600/Image+14.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
As I was the early adopter of this feature, Microsoft has extended my "Visual studio online Ultimate" version for free. After 62 days it will be a standard account with limited feature. You can get to know about all features or get it from <a href="http://www.visualstudio.com/en-us/products/visual-studio-online-Overview-vs" rel="nofollow" target="_blank">here</a>.<br />
<br />
<b>Features:</b><br />
<h2 style="-webkit-text-stroke-color: rgba(104, 33, 122, 0.2); -webkit-text-stroke-width: 1px; color: #68217a; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 2.16em; font-weight: normal; line-height: 34px; margin: 0px 0px 20px;">
</h2>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<table align="center" cellpadding="0" cellspacing="0" style="border-style: solid; border-width: 1px; color: #333333; line-height: 16px; margin: 15px 0px 0px; padding: 1px 1px 1px 1px; table-layout: fixed; width: 100%;"><thead style="font-family: 'Segoe UI Semibold', 'Segoe UI', Tahoma, Helvetica, sans-serif;">
<tr class="heading"><th class="left" style="border: none; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Categories and capabilities</th><th class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: none; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Visual Studio Online Advanced</th><th style="border: none; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Visual Studio Online Professional</th><th class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: none; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Visual Studio Online Basic</th><th style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: none none none solid; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Visual Studio Premium with MSDN</th></tr>
</thead><tbody>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Maximum number of users with this plan on an account</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Unlimited</td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">10 users</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Unlimited</td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;">Unlimited</td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Unlimited team projects and private, hosted code repos using TFVC or Git</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"> <img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"> <img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Project planning and bug tracking tools, including Kanban boards and team velocity forecasts</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"> <img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"> <img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Integration with popular development tools, including Visual Studio, Eclipse, and Xcode</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"> <img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"> <img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Work in one IDE to create solutions for the web, desktop, cloud, server, and phone</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Support for Office 365 business apps</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Track complex projects with hierarchical portfolio backlogs</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Visualize project data with work item chart authoring</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Discuss projects with teammates and monitor project events in Team Rooms</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Send feedback requests to users and stakeholders</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Manage and run tests and test plans</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
<tr class="content"><td class="left" style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 20px 15px 0px; vertical-align: middle; width: 337px;">Host team projects on-premises as well as in the cloud</td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td class="fill" style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border-style: solid none none; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"></td><td style="border-left-color: rgb(150, 150, 150); border-left-width: 1px; border-style: solid none none solid; border-top-color: rgb(150, 150, 150); border-top-width: 1px; min-height: 26px; padding: 15px 10px; text-align: center; vertical-align: middle;"><img alt="X" id="Table_Square_9X9_ppl" src="http://i.visualstudio.com/dynimg/IC688603.png" style="border: none; max-width: 100%;" title="X" /> </td></tr>
</tbody></table>
</div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<b><a href="http://www.visualstudio.com/get-started/overview-of-get-started-tasks-vs" target="_blank">Learn</a></b></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
Microsoft has provided detail documentation about how online TFS works. </div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
LIke following. I have provided Link for each. I will still give overview of How to setup Code with Visual studio.</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<ul style="text-align: left;">
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/en-us/get-started/set-up-vs" target="_blank">Setup</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/en-us/get-started/create-your-app-vs" rel="nofollow" target="_blank">Code</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/en-us/get-started/create-your-backlog-vs" rel="nofollow" target="_blank">Work</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/en-us/get-started/build-your-apps-vs" target="_blank">Build</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/en-us/get-started/create-a-test-plan-vs" target="_blank">Test</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/get-started/manage-your-release-vs" target="_blank">Deploy</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/en-us/get-started/find-performance-problems-vs" target="_blank">Insights</a></span></li>
<li><span style="font-size: 13px;"><a href="http://www.visualstudio.com/get-started/share-your-eclipse-projects-vs" rel="nofollow" target="_blank">Cross-Platform</a></span></li>
</ul>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT8HeJHa_tzyHgx3QiiCx6C07zuDav25MgqSHbFQpwoY8rkeLeIOaqo7HJ9RZydFle_Cp13dW0J5LvBmEuyPpU-m_YdR49qSaQ28V6MFhTeEPTq2ghcFO18gldU3M2Y57yQLRx4MfQB39B/s1600/Image+16.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT8HeJHa_tzyHgx3QiiCx6C07zuDav25MgqSHbFQpwoY8rkeLeIOaqo7HJ9RZydFle_Cp13dW0J5LvBmEuyPpU-m_YdR49qSaQ28V6MFhTeEPTq2ghcFO18gldU3M2Y57yQLRx4MfQB39B/s1600/Image+16.png" width="564" /></a></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<span style="font-size: 13px;"><b>Create Project </b></span></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
Go on your visual studio url {your username}.visualstudio.com. This is dashboard of all your project and project activities. Find "New" link under "Recent project & teams" to create New project. Check highlighted "New" link in following screen shot. </div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXw9kn05z03V8GljDyrLGZAj9AuLt6f70elrfE3YwOPga_qB7hyygtYs7XtdZIMWaCjcX05C6rNnHEsopNgK7GS70f8QbEyI4ltd5YMq29zpOVJ425vDnIKK1tCP8pHnaHpj8htQTbPQi8/s1600/Image+18.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXw9kn05z03V8GljDyrLGZAj9AuLt6f70elrfE3YwOPga_qB7hyygtYs7XtdZIMWaCjcX05C6rNnHEsopNgK7GS70f8QbEyI4ltd5YMq29zpOVJ425vDnIKK1tCP8pHnaHpj8htQTbPQi8/s1600/Image+18.png" width="640" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXw9kn05z03V8GljDyrLGZAj9AuLt6f70elrfE3YwOPga_qB7hyygtYs7XtdZIMWaCjcX05C6rNnHEsopNgK7GS70f8QbEyI4ltd5YMq29zpOVJ425vDnIKK1tCP8pHnaHpj8htQTbPQi8/s1600/Image+18.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXw9kn05z03V8GljDyrLGZAj9AuLt6f70elrfE3YwOPga_qB7hyygtYs7XtdZIMWaCjcX05C6rNnHEsopNgK7GS70f8QbEyI4ltd5YMq29zpOVJ425vDnIKK1tCP8pHnaHpj8htQTbPQi8/s1600/Image+18.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
Click on "New", It will open Modal window to create Project. You can insert Project Name, Description. You also can select Process Template and Version control. Microsoft has provided following Process Template. </div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<ul style="text-align: left;">
<li><span style="font-size: 13px;">Microsoft Visual Studio Scrum 2013</span></li>
<li><span style="font-size: 13px;">MSF for Agile Software Development 2013</span></li>
<li><span style="font-size: 13px;">MSF for CMMI Process Improvement 2013</span></li>
</ul>
<div>
These are the process followed by Software development team to develop software. </div>
<div>
<br /></div>
<div>
Microsoft has come up following two options for version control.</div>
<div>
<ul style="text-align: left;">
<li><span style="font-size: 13px;">Team Foundation Version Control</span></li>
<li><span style="font-size: 13px;">Git ( Github)</span></li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNIhqCxcS79F0r2xKJywvOx4H4CKI6p7Z9ZG-kyxRqtkoFaNbL6fDb3FMeGCqR-JbIabuL6KW9F9AhVB1kYUfhysRQFDSbL1-bDsk406v_e_HP2u-EbvIDMmRPev6SV1TMMOHoGobU8_1U/s1600/Image+20.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="542" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNIhqCxcS79F0r2xKJywvOx4H4CKI6p7Z9ZG-kyxRqtkoFaNbL6fDb3FMeGCqR-JbIabuL6KW9F9AhVB1kYUfhysRQFDSbL1-bDsk406v_e_HP2u-EbvIDMmRPev6SV1TMMOHoGobU8_1U/s1600/Image+20.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
</div>
<div>
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
After insert of all required details, you can create project by click on "Create project" button. It will crate project using selected Process template.</div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW9yBXH4g0ih0kVRBq68DGHBow8efyewrQR9z05VonS2n2SFE0JmX2OWBQRxc2dq9EwGYtVSFa7fWMsK5_2k7JIDtWI1MaJVnzbuqlWYDEoJzjy9u8FwGmyZIjDkZ6S_8XEgUdIMHxjRWC/s1600/Image+24.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="555" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW9yBXH4g0ih0kVRBq68DGHBow8efyewrQR9z05VonS2n2SFE0JmX2OWBQRxc2dq9EwGYtVSFa7fWMsK5_2k7JIDtWI1MaJVnzbuqlWYDEoJzjy9u8FwGmyZIjDkZ6S_8XEgUdIMHxjRWC/s1600/Image+24.png" width="640" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<b>Visual Studio with Online TFS</b></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
Go back to Visual studio. I am using Visual studio express 2013. I am going to show how can you connect your visual studio with your online TFS which you have configured above.</div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
Open Visual studio and click Menu link "TEAM". You will find sub menu link "Connect to Team Foundation Server..".</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
click on it.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDrhdrpDN-qCsA6hKeFWd_NZ8hj-YYU0uTk-4az77U58GtrLzfBbx3sH_I0-4PO3Pp8sq1YcL9K3N1dtjyWANIwG8p_mTIF9DqsSvRPAWnnwWgGDFqvCwnlBlnKLvWqsLFDZ56qL771Otg/s1600/Image+25.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="101" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDrhdrpDN-qCsA6hKeFWd_NZ8hj-YYU0uTk-4az77U58GtrLzfBbx3sH_I0-4PO3Pp8sq1YcL9K3N1dtjyWANIwG8p_mTIF9DqsSvRPAWnnwWgGDFqvCwnlBlnKLvWqsLFDZ56qL771Otg/s1600/Image+25.png" width="400" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
It opens "Team Explorer" tab at right side of VS window. Find connector icon on top. If you mouse hover on it it shows "Connect to Team Projects". Click on it. It opens small "Connect" tab. </div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj4EMjsxZ-Tee1cuAEv0UBfA-OkQdRJk8vZMKAghZl-5TBXCugyzxg7D3juVf36ObAfgLklA5EkZl9fEw5kcE6rsr0KeNeKHvvv5izoFObXMctUGZ3dvmCdsqFZLLAR-1BlOKEATPdRBVS/s1600/Image+27.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="262" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj4EMjsxZ-Tee1cuAEv0UBfA-OkQdRJk8vZMKAghZl-5TBXCugyzxg7D3juVf36ObAfgLklA5EkZl9fEw5kcE6rsr0KeNeKHvvv5izoFObXMctUGZ3dvmCdsqFZLLAR-1BlOKEATPdRBVS/s1600/Image+27.png" width="400" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
Click on "Connect" and it will popup screen for "Connect to Team Foundation Server".</div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif2zm-DfObHgnL14M1oW1uYW3tJK289nYN_9xi_dABDQsrWnm40aaSQA7b6rdgkxW12e35_u2pjfp8ClkRpR4FuTH_3ohJ8H_TsFzBjjIP7s-G8mrEmqbQqw1jQiLy4f_dVwC6Rtq-k0Et/s1600/Image+29.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="291" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif2zm-DfObHgnL14M1oW1uYW3tJK289nYN_9xi_dABDQsrWnm40aaSQA7b6rdgkxW12e35_u2pjfp8ClkRpR4FuTH_3ohJ8H_TsFzBjjIP7s-G8mrEmqbQqw1jQiLy4f_dVwC6Rtq-k0Et/s1600/Image+29.png" width="400" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
<br /></div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
Click on "Servers.." and it opens following another popup where you can add your own visual studio url which we have created before explained in above section. {yourusername}.visualstudio.com. Once you enter your url it will disable all other options like Path, protocol. online visual studio uses HTTPS. No need to select anything just your correct url is enough.</div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl79Y7LTXaO13h5G-htQ3DzLtAHkoDC2ZU1McY9J1H37nZu9KQRu1gxegkcwM9eE_y76AGXc5CeP6bmv0yYJYpYZsF8CVG7dPAEN1Ssw8iGv0r62DnTl-6l4Rr8TVTGpRCddc92KdLyafm/s1600/Image+30.png" imageanchor="1" style="clear: left; display: inline !important; font-size: 13px; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="267" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl79Y7LTXaO13h5G-htQ3DzLtAHkoDC2ZU1McY9J1H37nZu9KQRu1gxegkcwM9eE_y76AGXc5CeP6bmv0yYJYpYZsF8CVG7dPAEN1Ssw8iGv0r62DnTl-6l4Rr8TVTGpRCddc92KdLyafm/s1600/Image+30.png" width="400" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
Once you added TFS server. you can select same from servers drop down. It will show DefaultCollection in left tab and all projects on left side. You can find Project you have created online and explained in above section. check below screen shot.</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZFl_D_uBLhPnwTE_mbLGARDyW6qZy4_tH5ZeJrcOcz_r7MPg61KJPrZnI9VMelEPri42gmnSJyhCERbPzPI_64zlNqT5nCPrNL7aQKcP_bX_fiJUw_z-CvmhTGyLoK6UWQDZryp45yqyQ/s1600/Image+31.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZFl_D_uBLhPnwTE_mbLGARDyW6qZy4_tH5ZeJrcOcz_r7MPg61KJPrZnI9VMelEPri42gmnSJyhCERbPzPI_64zlNqT5nCPrNL7aQKcP_bX_fiJUw_z-CvmhTGyLoK6UWQDZryp45yqyQ/s1600/Image+31.png" width="400" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="compare" style="display: inline-block; width: 100%;" xmlns="">
On Team Explorer you will find your project. Click on Source Control Explorer.</div>
</div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgahfBdy9cJM8HX4-G8Tt0-vBhLuHKHJLBXTULOtX_Wy8eKU4F5EICT240Xo5LEV2TALWJueIqtl9_mXTl9KBdsIFBrvlc1ppe7OWvSPo-D331WQZEeBFPzUriWU7ux5d8VzDxnXPKDuj1h/s1600/Image+32.png" imageanchor="1" style="clear: left; display: inline !important; font-size: 13px; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgahfBdy9cJM8HX4-G8Tt0-vBhLuHKHJLBXTULOtX_Wy8eKU4F5EICT240Xo5LEV2TALWJueIqtl9_mXTl9KBdsIFBrvlc1ppe7OWvSPo-D331WQZEeBFPzUriWU7ux5d8VzDxnXPKDuj1h/s1600/Image+32.png" width="375" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
You can create your project folder and map it with your local drive. </div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsBzP5GOXV6-U3DybzCVFtwtMOMaPLXKsegTE03vAW6UcjNgJ4CerBVT2WmIC2C0yTjN8yYvCG9La2S2piCip51U930NzjHNoHXPrNBd9Mfrfkvkia7NTcGaZW6XM9vnKPy4PkdYPUjjy9/s1600/Image+33.png" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="187" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsBzP5GOXV6-U3DybzCVFtwtMOMaPLXKsegTE03vAW6UcjNgJ4CerBVT2WmIC2C0yTjN8yYvCG9La2S2piCip51U930NzjHNoHXPrNBd9Mfrfkvkia7NTcGaZW6XM9vnKPy4PkdYPUjjy9/s1600/Image+33.png" width="400" /></a></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
<br /></div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
Follow my previous blog to create project in TFS for more details <a href="http://atulkumarpatelsblog.blogspot.com/2013/01/tfs-tutorials-for-beginners.html" rel="nofollow" target="_blank">here</a>. </div>
<div class="RichText" style="-webkit-text-stroke-color: rgba(51, 51, 51, 0.2); -webkit-text-stroke-width: 1px; color: #333333; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 20px;" xmlns="http://www.w3.org/1999/xhtml">
Online TFS has all features of TFS including Project Management like Scrum dashboard, Tracking Product Backlog items, Sprint Backlog items, Scrum velocity charts, Bug Tracking, Automated Unit Testing, Load testing, Automatic Build Deployment, also has support with Windows Azure. <br />
<br />
In my next blog I will try to cover how to manage Scrum Dashboard, Create Product backlog items, how to track Bug etc. <br />
Thank you.<br />
~Atul<br />
<br /></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com4tag:blogger.com,1999:blog-3416772542415993289.post-76062630889748439812013-08-08T15:28:00.000-05:002013-08-08T15:31:22.453-05:00ASP.Net, C# new feature note<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
</div>
<h3 style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px; font-weight: normal;">When I was reading, I came across few new things in asp.net and C# and also some topics which i always keep forgetting. I tried to make some small note of all those topics so next time no need to read everything in detail. Mostly I refer MSDN for these topics, I've attached url also for few.</span></span></h3>
<h3 style="text-align: left;">
<b style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-large;">Redirect to another page</b></h3>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: white; font-size: 14px;"><b>Response.Redirect:</b> requires round trip. It send message to browser to to send new request. It is a GET request from browser.</span><br style="font-size: 14px;" /><span style="background-color: white; font-size: 14px;"><b>Server.Transfer()</b> : Faster then Response.Redirect. It transfers the execution of one page to another.</span><br style="font-size: 14px;" /><span style="background-color: white;"><span style="font-size: 14px;">It does not change url in to browser if transferred.</span></span><br style="font-size: 14px;" /><span style="background-color: white; font-size: 14px;">Unable to Transfer page of different Application or non .net Application.</span><br style="font-size: 14px;" /><span style="background-color: white; font-size: 14px;"><b>CrossPagePosting:</b> It post page to another page by copying viewstate and content of another controls. Whichever control implements IButtonControl interface can set cross page posting. </span></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: white; font-size: 14px;"> - Target page can access properties of previous page using "PreviousPage" property.</span></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: white; font-size: 14px;"> - It post one page content to another via Http Post method same like we did in classic ASP.</span></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: white; font-size: 14px;"> - Server.Transfer is server based operation whether cross Page posting is client base posting.</span></span></div>
<div style="text-align: left;">
for more info: <a href="http://msdn.microsoft.com/en-us/library/ms178139(v=vs.100).aspx">http://msdn.microsoft.com/en-us/library/ms178139(v=vs.100).aspx</a></div>
<div style="text-align: left;">
<br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Response.RedirectPermanent():</b> it is same as response.redirect() but instead of using HTTP status 302 it uses HTTP status 301. It is important for search engine. it’s important for search engines. If a search engine’s web crawler is exploring your website and it receives the 301 status code, it will update the search catalog with the new URL</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">information.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><b><span style="font-size: large;">ASP.net HTTP Handler and Module</span></b><span style="font-size: 14px;">: </span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">HTTP modules differ from HTTP handlers. An HTTP handler returns a response to a request that is identified by a file name extension or family of file name extensions. </span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">In contrast, an HTTP module is invoked for all requests and responses. It subscribes to event notifications in the request pipeline and lets you run code in registered event handlers. The tasks that a module is used for are general to an application and to all requests for resources in the application</span><br />
<br style="font-size: 14px;" />
<br style="font-size: 14px;" />
<span style="font-size: large;"><span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><b>Named arguments (C# 4.0)</b></span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Rather than identifying an argument by position, you can identify an argument by</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">name. For example:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">void Foo (int x, int y) { Console.WriteLine (x + ", " + y); }</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">void Test()</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">{</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> Foo (x:1, y:2); // 1, 2</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">}</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Named arguments can occur in any order. The following calls to Foo are semantically </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">identical:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Foo (x:1, y:2);</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Foo (y:2, x:1);</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">A subtle difference is that argument expressions are evaluated</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">in the order in which they appear at the calling site. In general,</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">this makes a difference only with interdependent side-effecting</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">expressions such as the following, which writes 0, 1:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">int a = 0;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Foo (y: ++a, x: --a); // ++a is evaluated first</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Of course, you would almost certainly avoid writing such code</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">in practice!</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">You can mix named and positional parameters:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Foo (1, y:2);</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">However, there is a restriction: positional parameters must come before named arguments.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">So we couldn’t call Foo like this:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Foo (x:1, 2); // Compile-time error</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Named arguments are particularly useful in conjunction with optional parameters.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">For instance, consider the following method:</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">void Bar (int a = 0, int b = 0, int c = 0, int d = 0) { ... }</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">We can call this supplying only a value for d as follows:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Bar (d:3);</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">This is particularly useful when calling COM APIs</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;"><b>The 'as' operator</b></span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The as operator performs a downcast that evaluates to null (rather than throwing</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">an exception) if the downcast fails:</span></div>
<div style="text-align: left;">
<i><span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Asset a = new Asset();</span><br style="font-size: 14px;" /><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Stock s = a as Stock; // s is null; no exception thrown</span></i><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">This is useful when you’re going to subsequently test whether the result is null:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><i>if (s != null) Console.WriteLine (s.SharesOwned); </i></span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">NOte:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Without such a test, a cast is advantageous, because if it fails, a</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">more descriptive exception is thrown. We can illustrate by comparing</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">the following two lines of code:</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">int shares = ((Stock)a).SharesOwned; // Approach #1</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">int shares = (a as Stock).SharesOwned; // Approach #2</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">If a is not a Stock, the first line throws an InvalidCastExcep</span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">tion, which is an accurate description of what went wrong. The</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">second line throws a NullReferenceException, which is ambiguous.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Was a not a Stock or was a null?</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">NOte:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The as operator cannot perform custom conversions and it cannot do numeric conversions:</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">long x = 3 as long; // Compile-time error</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The as and cast operators will also perform upcasts, although</span><span style="background-color: white; font-size: 14px;"> </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">this is not terribly useful because an implicit conversion will do </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">the job.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;"><b>The 'is' operator</b></span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The is operator tests whether a reference conversion would succeed; in other words,</span><span style="background-color: white; font-size: 14px;"> </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">whether an object derives from a specified class (or implements an interface). It is </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">often used to test before down casting.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">if (a is Stock)</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Console.WriteLine (((Stock)a).SharesOwned);</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The is operator does not consider custom or numeric conversions, but it does consider </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">unboxing conversions </span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;"><b>'new' Keyword</b></span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Occasionally, you want to hide a member deliberately, in which case you can apply</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">the 'new' modifier to the member in the subclass. The new modifier does nothing more </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">than suppress the compiler warning that would otherwise result:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">public class A { public int Counter = 1; }</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">public class B : A { public new int Counter = 2; }</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The new modifier communicates your intent to the compiler—and other</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">programmers—that the duplicate member is not an accident.</span><span style="background-color: white; font-size: 14px;"> </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">C# overloads the new keyword to have independent meanings</span><span style="background-color: white; font-size: 14px;"> </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">in different contexts. Specifically, the new operator is different</span><span style="background-color: white; font-size: 14px;"> </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">from the new member modifier. </span><br />
<br style="font-size: 14px;" />
<b style="font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;">Structs</span></b><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">A struct is similar to a class, with the following key differences:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">• A struct is a value type, whereas a class is a reference type.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">• A struct does not support inheritance (other than implicitly deriving from</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">object, or more precisely, System.ValueType).</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">A struct can have all the members a class can, except the following:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">• A parameter less constructor</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">• A finalizer</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">• Virtual members</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">A struct is used instead of a class when value-type semantics are desirable. Good</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">examples of structs are numeric types, where it is more natural for assignment to</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">copy a value rather than a reference. Because a struct is a value type, each instance </span><span style="background-color: white;"><span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;">does not require instantiate of an object on the heap; this incurs a useful savings </span></span></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">when creating many instances of a type. For instance, creating an array of value type </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">requires only a single heap allocation. </span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;"><b>Access Modifiers</b></span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">To promote encapsulation, a type or type member may limit its accessibility to other </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">types and other assemblies by adding one of five access modifiers to the declaration:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>public</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Fully accessible; the implicit accessibility for members of an enum or interface</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>internal</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Accessible only within containing assembly or friend assemblies; the default</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">accessibility for non-nested types</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>private</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Visible only within containing type; the default accessibility members of a class</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">or struct</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>protected</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Visible only within containing type or sub classes</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>protected internal</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The union of protected and internal accessibility (this is less restrictive than</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">protected or internal alone) </span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><b><span style="font-size: large;">Delegates</span></b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> A delegate dynamically wires up a method caller to its target method. The caller invokes the </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">delegate, and then the delegate calls the target method. This indirection decouples </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">the caller from the target method.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">-<b>Multicast delegate</b> : Delegate can reference list of target methods. + and += operator combines delegate </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">instance. -= will remove delegate instance.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- Delegates are immutable, so when you call += or -=, you’re in fact creating a new delegate instance and </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">assigning it to the existing variable.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">-When a delegate object is assigned to an instance method, the delegate object must maintain a reference not </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">only to the method, but also to the instance to which the method belongs. The System.Delegate class’s Target</span><span style="background-color: white; font-size: 14px;"> </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">property represents this instance (and will be null for a delegate referencing a static method).</span><br />
<br style="font-size: 14px;" />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;"><b>Yield Statement</b></span></span><br />
<span style="background-color: white;"><span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;">while iteration On "yield return" statement control is returned to caller, but calle's state is maintained so that method can continue execution as soon as callers enumerates the next element. Lifetime of this state of calle's bound to enumerator such that the state can be released when the caller has finished enumerating.</span></span></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">using System;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">using System.Collections.Generic;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;">class Test</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> {</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> static void Main()</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> {</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> foreach (int fib in Fibs(6))</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> Console.Write(fib + " ");</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> }</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> static IEnumerable<int> Fibs(int fibCount)</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> {</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> for (int i = 0, prevFib = 1, curFib = 1; i < fibCount; i++)</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> {</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> yield return prevFib;</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> int newFib = prevFib + curFib;</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> prevFib = curFib;</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> curFib = newFib;</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> }</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> }</span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: white; font-size: 14px;"></span></span><br />
<span style="font-family: Courier New, Courier, monospace;"><span style="font-size: 14px;"> }</span></span><br />
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">OUTPUT: 1 1 2 3 5 8</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The compiler converts iterator methods into private classes that implement IEnumerable<T> and/or IEnumerator<T>. The logic within the iterator block is “inverted” and spliced into the MoveNext method and Current property on the compiler-written enumerator class. This means that when you call an iterator</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">method, all you’re doing is instantiating the compiler-written class; none of your code actually runs! Your code runs only when you start enumerating over the resultant sequence, typically with a foreach statement.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><span style="font-size: large;"><b>yield break</b></span></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The yield break statement indicates that the iterator block should exit early, without </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">returning more elements. We can modify Foo as follows to demonstrate:</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
<div style="text-align: left;">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">static IEnumerable<string> Foo (bool breakEarly)</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">{</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> yield return "One";</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> yield return "Two";</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> if (breakEarly)</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> yield break;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> yield return "Three";</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">}</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br style="font-size: 14px;" /></span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- A yield return statement cannot appear in a try block that has a catch clause:</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- Composing Sequences (check C# 4.0 Nutshell 4th edition page 167 )</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: large;"><b>Null Coalescing Operator ??</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- Can be used with Nullable and Reference type.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- If oprand is not null then it takes value and assigned otherwise it assin default value.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">int? x = null;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">int y = x ?? 5; // y is 5</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">int? a = null, b = 1, c = 2;</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Console.WriteLine (a ?? b ?? c); // 1 (first non-null value) </span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- This frequently occurs in database programming, where a class is mapped to a table with nullable columns.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: large;"><b>MVP and MVC Pattern</b></span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">The MVP pattern is a UI presentation pattern based on the concepts of the MVC pattern. The pattern separates responsibilities across four components: the view is responsible for rending UI elements, the view interface is used to loosely couple the presenter from its view, the presenter is responsible for interacting between the view/model, and the model is responsible for business behaviors and state management. In some implementations the presenter interacts with a service (controller) layer to retrieve/persist the model. The view interface and service layer are commonly used to make writing unit tests for the presenter and the model easier.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Key Benefits</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Before using any pattern a developers needs to consider the pros and cons of </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">using it. There are a number of key benefits to using either the MVC or MVP pattern (See list below). But, there also a few draw backs to consider. The biggest drawbacks are additional complexity and learning curve. While the patterns may not be appropriate for simple solutions; advance solutions can greatly benefit from using the pattern. I’m my experience a have seen a few solutions eliminate a large amount of complexity but being re-factored to use either pattern.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Loose coupling</b> – </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> The presenter/controller are an intermediary between the UI code and the model. This allows the view and the model to evolve independently of each other.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b><br /></b></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Clear separation of concerns/responsibility</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> o UI (Form or Page) – Responsible for rending UI elements</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> o Presenter/controller – Responsible for reacting to UI events and interacts with the model</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"> o Model – Responsible for business behaviors and state management</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b><br /></b></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Test Driven</b> – By isolating each major component (UI, Presenter/controller, and model) it is easier to write unit tests. This is especially true when using the MVP pattern which only interacts with the view using an interface.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b><br /></b></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Code Reuse</b> – By using a separation of concerns/responsible design approach you will increase code reuse. This is especially true when using a full blown domain model and keeping all the business/state management logic where it belongs.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Hide Data Access</b> – Using these patterns forces you to put the data access code where it belongs in a data access layer. There a number of other patterns that typical works with the MVP/MVC pattern for data access. Two of the most common ones are repository and unit of work. (See Martin Fowler – Patterns of Enterprise Application Architecture for more details)</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Flexibility/Adaptable</b> – By isolating most of your code into the presenter/controller and model components your code base is more adaptable to change. For example consider how much UI and data access technologies have changed over the years and the number of choices we have available today. A properly design solution using MVC or MVP can support multi UI and data access technologies at the same time.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>Key Differences:</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">So what really are the differences between the MVC and MVP pattern. Actually there are not a whole lot of differences between them. Both patterns focus on separating responsibility across multi components and promote loosely coupling the UI (View) from the business layer (Model). The major differences are how the pattern is implemented and in some advanced scenarios you need both presenters and controllers.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace;"><b>Here are the key differences between the patterns:</b></span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>MVP Pattern</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">o View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">o Easier to unit test because interaction with the view is through an interface</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">o Usually view to presenter map one to one. Complex views may have multi presenters.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><b>MVC Pattern</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">o Controller are based on behaviors and can be shared across views</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">o Can be responsible for determining which view to display (Front Controller Pattern)</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: large;"><b>Repository Pattern.</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">It is a one layer of abstraction which isolate domain objects from database access code and acting like in </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">memory domain object. </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- It helps where large number of domain classes exists or heavy querying exists. It minimize duplicate query </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">logic.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- Repository encapsulates the set of objects persisted in a data store and the operations performed over </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">them, providing a more object-oriented view of the persistence layer. </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- Repository also supports the objective of achieving a clean separation and one-way dependency between the </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">domain and data mapping layers.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- You want to maximize the amount of code that can be tested with automation and to isolate the data layer </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">to support unit testing.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">It centralizes the data logic or Web service access logic.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">It provides a substitution point for the unit tests.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">It provides a flexible architecture that can be adapted as the overall design of the application evolves.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Check for more info (http://msdn.microsoft.com/en-us/library/ff649690.aspx)</span><br />
<br style="font-size: 14px;" />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: large;"><b>Unit of work Pattern</b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">This pattern keeps track of everything happened during business transaction that affect to database.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Maintains a list of objects affected by a business transaction and coordinates the writing out of changes </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">and the resolution of concurrency problems.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- If you update database for very small changes then it will increase the database call which end up very </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">slow. It also requires you to open transaction that spans multiple business request.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- A Unit of Work keeps track of everything you do during a business transaction that can affect the </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">database. When you're done, it figures out everything that needs to be done to alter the database as a result of your work.</span><br />
<br style="font-size: 14px;" />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: large;"><b>Data Mapper Pattern: </b></span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">A layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- Objects and relational databases have different mechanisms for structuring data. Many parts of an object, such </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">as collections and inheritance, aren't present in relational databases. When you build an object model with a </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">lot of business logic it's valuable to use these mechanisms to better organize the data and the behavior that </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">goes with it. Doing so leads to variant schemas; that is, the object schema and the relational schema don't </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">match up.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">- The Data Mapper is a layer of software that separates the in-memory objects from the database. Its </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">responsibility is to transfer data between the two and also to isolate them from each other. With Data </span><span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">Mapper the in-memory objects needn't know even that there's a database present; they need no SQL interface </span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;">code, and certainly no knowledge of the database schema.</span><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span>
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px;"><br /></span></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com4tag:blogger.com,1999:blog-3416772542415993289.post-22744023248126981102013-01-29T18:07:00.002-06:002014-07-18T00:12:09.538-05:00TFS tutorials for beginners<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWoMPGKkN6rsCBFa8odX-nkdLTo4Ql09UTRxwqOPd-pTNBFpTbG98g41H291hC3mwHVTxRGWadnbHcGFb5QyIiyzGCDafZe22TDUzO86vrgRwyPmH5piGtowooQLZcDGJBT6RjKZAaiqC0/s1600/TFS5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><br /></a>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<b>What is TFS?</b></div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
It is a team foundation server. It is a central
repository or storage with version
control. Initially Microsoft has VSS(Visual source safe ) for version control.
TFS is new extended version of VSS with lot of new features and capabilities.<o:p></o:p></div>
<div class="MsoNormal">
Three major features<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
</div>
<ul style="text-align: left;">
<li><span style="font-size: 7pt; text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">Source Control</span></li>
<li><span style="font-size: 7pt; text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;">Builds</span></li>
<li><span style="text-indent: -0.25in;">Work Items</span></li>
</ul>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<o:p></o:p></div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .25in;">
We will discuss all of above
shortly. Lets start with connect to TFS
server with images.<o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
In order to connect TFS from visual studio. Click on Team menu and click on "Connect to Team Foundation Server.." You can do it same from Start page also.</div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTbP4GH-lSgSw4UBgpU8qQQ9SHD6rw1Vr7FqIqNj86kbc2_Ctq5HIds3g-IHnp7nONI933XcqpbIfpd74AbLRy-9CS8kTCsJ7Y2LpikKTISoaUSAqn6Btnj6RBdySel3NSVi1QXKg9elhc/s1600/TFS1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTbP4GH-lSgSw4UBgpU8qQQ9SHD6rw1Vr7FqIqNj86kbc2_Ctq5HIds3g-IHnp7nONI933XcqpbIfpd74AbLRy-9CS8kTCsJ7Y2LpikKTISoaUSAqn6Btnj6RBdySel3NSVi1QXKg9elhc/s640/TFS1.png" height="456" width="640" /></a></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
It will open following dialog box. Click on "Servers.." button.</div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuRmzR45iU7AlH2tpRyins6H7OsBKdJ150iTICgEv7WTY2fjFZXUte1DqqptTLhnNcMpp4AUeF8WIcXlDQSFXbElI_EjYhYyDGd9kefyyZRl8WqeESvWIzSAw3Wl3r-E9MOkIwT0yw4T6h/s1600/TFS2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuRmzR45iU7AlH2tpRyins6H7OsBKdJ150iTICgEv7WTY2fjFZXUte1DqqptTLhnNcMpp4AUeF8WIcXlDQSFXbElI_EjYhYyDGd9kefyyZRl8WqeESvWIzSAw3Wl3r-E9MOkIwT0yw4T6h/s640/TFS2.png" height="404" width="640" /></a></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
You can add your TFS server here by clicking on Add button.</div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMO_bBi1iSbXDWTDIm2t9YTijp-3LGeTgMMFpDZ_UGP12riDkExNvZn3AnMM7u8ZX8dcgoM82HP92m_0GHNlm2MyWvfn3NXjjt3IPNWFlTURp8qoyorWBZnw2FqtpHBDOKWKpv0f36Nzj2/s1600/TFS3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMO_bBi1iSbXDWTDIm2t9YTijp-3LGeTgMMFpDZ_UGP12riDkExNvZn3AnMM7u8ZX8dcgoM82HP92m_0GHNlm2MyWvfn3NXjjt3IPNWFlTURp8qoyorWBZnw2FqtpHBDOKWKpv0f36Nzj2/s640/TFS3.png" height="393" width="640" /></a></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
<!--[if gte vml 1]><v:shapetype
id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="Picture_x0020_1" o:spid="_x0000_i1026" type="#_x0000_t75"
style='width:351pt;height:250.5pt;visibility:visible;mso-wrap-style:square'>
<v:imagedata src="file:///C:\Users\akpatel\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"
o:title=""/>
</v:shape><![endif]--><!--[if !vml]--><span style="font-family: Verdana, sans-serif;"></span><!--[endif]--><o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
Add TFS server Name. If you have additional path after server then you can add it in Path text box. It will show final TFS url in preview section.<br />
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEpPyNa3FiP6PmEoF0T8yWriYH8WDMMfdF8VHdk59ScZm6VbBy5iXg73oE5mU1Ww2IRJ3dc0WLjWWuJOIfC2vRyPCfZuZY8OObrsdd-Vad3gAyLb7lFGOb_YkKo73cs-NwDvlKBczhgaUC/s1600/TFS4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEpPyNa3FiP6PmEoF0T8yWriYH8WDMMfdF8VHdk59ScZm6VbBy5iXg73oE5mU1Ww2IRJ3dc0WLjWWuJOIfC2vRyPCfZuZY8OObrsdd-Vad3gAyLb7lFGOb_YkKo73cs-NwDvlKBczhgaUC/s640/TFS4.png" height="408" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<o:p> Once you add url, you will get following like dialog box window, where you can find all team projects. you can select your project by check it and click on "Connect".</o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWoMPGKkN6rsCBFa8odX-nkdLTo4Ql09UTRxwqOPd-pTNBFpTbG98g41H291hC3mwHVTxRGWadnbHcGFb5QyIiyzGCDafZe22TDUzO86vrgRwyPmH5piGtowooQLZcDGJBT6RjKZAaiqC0/s1600/TFS5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWoMPGKkN6rsCBFa8odX-nkdLTo4Ql09UTRxwqOPd-pTNBFpTbG98g41H291hC3mwHVTxRGWadnbHcGFb5QyIiyzGCDafZe22TDUzO86vrgRwyPmH5piGtowooQLZcDGJBT6RjKZAaiqC0/s640/TFS5.png" height="400" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After connect it opens Team explorer window in visual studio. Which has sections like Documents, Reports, Work Items, Builds, Source Control.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9k-LUNCbFYr4ilM6fE0Hl8DKC7ct1BBcK07nnknkNY4N9nSJA4U9Gsr0qUwolATfPu7cFUm21YpUcqHanLDcPayr_iykyZAhrooOZAe0gHr0bfC_U8rFOfIWxJ-Xduwx3IA5jhjxOrGDQ/s1600/TFS6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9k-LUNCbFYr4ilM6fE0Hl8DKC7ct1BBcK07nnknkNY4N9nSJA4U9Gsr0qUwolATfPu7cFUm21YpUcqHanLDcPayr_iykyZAhrooOZAe0gHr0bfC_U8rFOfIWxJ-Xduwx3IA5jhjxOrGDQ/s640/TFS6.png" height="640" width="328" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Source control opens following like explorer in visual studio. Select your project folder. that project folder should be mapped with your local machines folder. If it is not mapped then it shows at Local Path section as "Not mapped". Click on "Not mapped" link and you can map TFS folder with local machine folder.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqP_k_pp59sg10t7WeBNG5yLU4_Qhes0hLLy1RjMS5pduhGrR-qivxAC_GqVt10wy3jbsS8IPnNTteJqk6cN0eSTxCLu8SRbmdYS8m7CTZ_XHpTXRf_qCpXYKelWFghncxWbS8UYCjWt79/s1600/TFS7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqP_k_pp59sg10t7WeBNG5yLU4_Qhes0hLLy1RjMS5pduhGrR-qivxAC_GqVt10wy3jbsS8IPnNTteJqk6cN0eSTxCLu8SRbmdYS8m7CTZ_XHpTXRf_qCpXYKelWFghncxWbS8UYCjWt79/s640/TFS7.png" height="465" width="640" /></a></div>
<br />
It opens following like window. you can insert your local machine path to map folder. once you click on "Map" button. It downloads all source code files from TFS server to your local machine mapped folder.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG81lL5EEl5XmNQB8CX7JC_troKbt642CURFupEtfWZQyfSpm60bB2kiBJCPQjTuM_eyFWfnN0zq7Lrx4yw3-J2bpDtrcC2bOjj4IEKNbaJRYw85J9orASqIf5wEvgtqb2a2M8C4LaL0AS/s1600/TFS7-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG81lL5EEl5XmNQB8CX7JC_troKbt642CURFupEtfWZQyfSpm60bB2kiBJCPQjTuM_eyFWfnN0zq7Lrx4yw3-J2bpDtrcC2bOjj4IEKNbaJRYw85J9orASqIf5wEvgtqb2a2M8C4LaL0AS/s640/TFS7-2.png" height="187" width="640" /></a></div>
<br />
It will show following like explorer after mapping. you can find your .sln (solution) file and directly open from there.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7eDWqQ4Los-cd-OHElg-E0fn_T9QRb_ZTH1W4RwQArAnTVh74Isf16jcZQR5w_hAWtbbW6xsDpiPlR_vOzsvw2L2r7Qx2L2ZnNb7DBNnN00uLxzVihGxPdWZciu87gxcAL0q5zJnyw35V/s1600/TFS8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7eDWqQ4Los-cd-OHElg-E0fn_T9QRb_ZTH1W4RwQArAnTVh74Isf16jcZQR5w_hAWtbbW6xsDpiPlR_vOzsvw2L2r7Qx2L2ZnNb7DBNnN00uLxzVihGxPdWZciu87gxcAL0q5zJnyw35V/s640/TFS8.png" height="329" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: left;">You can see different symbol for particular files. </span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: left;"> "+" is for newly added file</span></div>
"right mark" for checked out file.<br />
"lock" for checked in file<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDIlZwU2r8GDEYSZMfVG5f58Cx2O8w7alI1Yn7oKlVJPcTqtKjcMymY-5Qxa-JJ2JWozkvnrNSOwJxCEGk-gxW_3qLmtqLVctopko7noVtC0AJEz20r6iYq0B6Ghmc1SKr4tiQ2-5pBV_h/s1600/TFS9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDIlZwU2r8GDEYSZMfVG5f58Cx2O8w7alI1Yn7oKlVJPcTqtKjcMymY-5Qxa-JJ2JWozkvnrNSOwJxCEGk-gxW_3qLmtqLVctopko7noVtC0AJEz20r6iYq0B6Ghmc1SKr4tiQ2-5pBV_h/s640/TFS9.png" height="640" width="372" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h3 style="text-align: left;">
<b>Add new file</b></h3>
<div class="separator" style="clear: both; text-align: left;">
You can add new file from project solution and it will automatically added to TFS and shows as "+" symbol. you also can add existing file to TFS from Source Control explorer by right click and "Add items to folder".</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5twtNkqL2LZy1Jyz6FkhbxD5nAb3nh0AxVc5VnExS2JEFNlE5HLMyN4bvHcTBk7vN7hh_lVVIMnzYyaBoQ0zEhpiE_MFGfTlegu2Jy6J18aEyN5bP5Kqe0qS7fU080Nqmm_Ek537F74yH/s1600/TFS10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5twtNkqL2LZy1Jyz6FkhbxD5nAb3nh0AxVc5VnExS2JEFNlE5HLMyN4bvHcTBk7vN7hh_lVVIMnzYyaBoQ0zEhpiE_MFGfTlegu2Jy6J18aEyN5bP5Kqe0qS7fU080Nqmm_Ek537F74yH/s640/TFS10.png" height="640" width="392" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<h3 style="text-align: left;">
<b>Check out</b></h3>
<br />
<div class="separator" style="clear: both; text-align: left;">
If you want to change already existing file then you need to checked out it first. It will lock files for other users and available for you in edit mode. checked out file shows in "right mark" symbol.</div>
<div class="separator" style="clear: both; text-align: left;">
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5twtNkqL2LZy1Jyz6FkhbxD5nAb3nh0AxVc5VnExS2JEFNlE5HLMyN4bvHcTBk7vN7hh_lVVIMnzYyaBoQ0zEhpiE_MFGfTlegu2Jy6J18aEyN5bP5Kqe0qS7fU080Nqmm_Ek537F74yH/s1600/TFS10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5twtNkqL2LZy1Jyz6FkhbxD5nAb3nh0AxVc5VnExS2JEFNlE5HLMyN4bvHcTBk7vN7hh_lVVIMnzYyaBoQ0zEhpiE_MFGfTlegu2Jy6J18aEyN5bP5Kqe0qS7fU080Nqmm_Ek537F74yH/s640/TFS10.png" height="640" width="392" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h3 style="text-align: left;">
Check in</h3>
<div>
After finished working on file you can commit your changes back to TFS by check in them. you can check single file by right click on that file from solution explorer in visual studio and click on "Check in".</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRIjEgzIqNbQzbx__B-2oPiI9vrAuFoGdXUJuzTmN45oAboHv1AXwieyr_Toai_J06SizGnp1ubwKHMJAeK_o78hrVc9j6_gMfBu158MAw0TMGv3bIznJeZSjNgf0n-fF40YCE8OmrQ9c4/s1600/TFS12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRIjEgzIqNbQzbx__B-2oPiI9vrAuFoGdXUJuzTmN45oAboHv1AXwieyr_Toai_J06SizGnp1ubwKHMJAeK_o78hrVc9j6_gMfBu158MAw0TMGv3bIznJeZSjNgf0n-fF40YCE8OmrQ9c4/s640/TFS12.png" height="640" width="468" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
You can add your comments like what change you have done etc. on comments box. you can see all related files only has checked for check in following image.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYH2hNptDR_YA11ks6IYHUh-c087Oks32EpS-qOTJC98tMT_Z6eBzxHS18y7kGltLu4E1eKjqCudvulqk-CL1p-r284jRYhb_1uwOtaLMmBXggj1KO6geEVzAZ6UawKzWUztCITRjTo3vn/s1600/TFS13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYH2hNptDR_YA11ks6IYHUh-c087Oks32EpS-qOTJC98tMT_Z6eBzxHS18y7kGltLu4E1eKjqCudvulqk-CL1p-r284jRYhb_1uwOtaLMmBXggj1KO6geEVzAZ6UawKzWUztCITRjTo3vn/s640/TFS13.png" height="438" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
You can also check in multiple file by opening "View Pending changes" window in visual studio. you can select multiple files from there by checked them and check in together. you can also attach "Work Item" for each check in. Check in will create new Change set in TFS. it will be new unique changes set number assigned for each change set. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjre31_6HcLAhbSyZKh6OXYKL71G1IvOTbT4GyQ-XMxL_TbJgmrtxRck1XED4Pmn2A8Gr4I2RmA2P0tS_3zdCzoyrOXvTdOvzqKvqyWBLZ_fxesBQMn9rxecUHLlDFC_y_H6ZXAYQbbZH7x/s1600/TFS14.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjre31_6HcLAhbSyZKh6OXYKL71G1IvOTbT4GyQ-XMxL_TbJgmrtxRck1XED4Pmn2A8Gr4I2RmA2P0tS_3zdCzoyrOXvTdOvzqKvqyWBLZ_fxesBQMn9rxecUHLlDFC_y_H6ZXAYQbbZH7x/s640/TFS14.png" height="264" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Added more info <a href="http://atulkumarpatelsblog.blogspot.com/2014/01/tfs-with-vs-2013-tutorial.html" target="_blank">here</a> (http://atulkumarpatelsblog.blogspot.com/2014/01/tfs-with-vs-2013-tutorial.html)</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
Atul Patelhttp://www.blogger.com/profile/00718702987615010574noreply@blogger.com66Plano, TX, USA33.0198431 -96.69888559999998332.806917600000006 -97.021609099999978 33.2327686 -96.376162099999988