<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3742387115082650335</id><updated>2024-11-01T12:40:35.171+01:00</updated><category term="c#"/><category term="JavaScript"/><category term="entity framework"/><category term="jQuery"/><category term=".NET"/><category term="ASP.NET MVC"/><category term="DTD"/><category term="Knockout"/><category term="Linq to XML"/><category term="WCF Data Service"/><category term="ajax"/><category term="asp.net"/><category term="date"/><category term="earthquakes"/><category term="entitydatasource"/><category term="html5"/><category term="isolation level"/><category term="linq"/><category term="multiple file upload"/><category term="objectquery"/><category term="report"/><category term="spire data export"/><category term="sql"/><category term="terremoti"/><category term="transactions"/><category term="visual studio 2008"/><category term="windows phone 7"/><category term="xml"/><title type='text'>Programmers&#39; corner</title><subtitle type='html'>Tips &amp;amp; Tricks, info about &amp;quot;magic&amp;quot; programmers&amp;#39; World</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-2274927832945089810</id><published>2012-12-02T21:59:00.002+01:00</published><updated>2012-12-02T22:00:49.869+01:00</updated><title type='text'>Visual Studio 2012 Update 1</title><content type='html'>&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;It&#39;s now possible download Update 1 for VS 2012. &lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Most of the new functionality appears in Ultimate and Premium and primarily spans these four areas:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Windows development&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;SharePoint development&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Agile teams&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Continuous quality&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;More info here:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;a href=&quot;http://www.microsoft.com/visualstudio/ita/visual-studio-update#story-update-1&quot; target=&quot;_blank&quot;&gt;http://www.microsoft.com/visualstudio/ita/visual-studio-update#story-update-1&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/2274927832945089810/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2012/12/visual-studio-2012-update-1.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2274927832945089810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2274927832945089810'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2012/12/visual-studio-2012-update-1.html' title='Visual Studio 2012 Update 1'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-2010354466426526077</id><published>2012-08-01T22:48:00.000+02:00</published><updated>2012-08-02T12:07:02.952+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="Knockout"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF Data Service"/><title type='text'>WCF Data Service and Knockoutjs</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;One of the strengths of modern websites is the use of client side technologies.In fact there are several libraries that can help us develop our work and are among the most popular jQuery.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;Using these libraries we can more easily interact with the DOM (Document Object Model) than using the traditional JavaScript functions.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;Furthermore, the ajax functions are much simpler to implement.&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;With jQuery, you can do many things, but not all ... or you can do them but some become very complex, such as dynamically create an html select tag. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;Here a very basic example with jQuery:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;//a simple continents array&lt;br /&gt;someContinents = { &quot;1&quot;: &quot;EUROPE&quot;, &quot;2&quot;: &quot;AMERICA&quot;, &quot;3&quot;: &quot;ASIA&quot;, &quot;4&quot;: &quot;AFRICA&quot; };&lt;br /&gt;&lt;br /&gt;$.each(someContinents, function (k, v) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;select#selContinents&#39;).append($(&quot;&quot;).attr(&quot;value&quot;, k).text(v));&lt;br /&gt;});&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;With a foreach jQuery function ($.each) we can iterate all elements (continents). Every iteration append an &quot;option&quot; html tag (with key and value) to html select tag. This is a very very simple example. Your data can come from several sources (webservice, array...).&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;Now introduce another way to populate a combo box, using less JavaScript code and a very powerful library: Knockout. It does not replace jQuery, but we can say that it can be an integration.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;But we go one step at a time…&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;First, we create a sample table on a MS SQL database called “T_STATE” with two columns: id and description. Then populate it with some data like these:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-fareast-language: IT; mso-no-proof: yes;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3WXNGmHCbAPiJiBMyRgtu2S1KVqChBqw6lQSHw2tknl5c1DbrGRdEkg94zuefKMCB8m6rN1SVRcliEDk2di7kVFReKzr3ucil7r6EpzfGSDPjCSEkz4ETYRO5XP9qNo2m9nAT82-EoDmv/s1600/01.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3WXNGmHCbAPiJiBMyRgtu2S1KVqChBqw6lQSHw2tknl5c1DbrGRdEkg94zuefKMCB8m6rN1SVRcliEDk2di7kVFReKzr3ucil7r6EpzfGSDPjCSEkz4ETYRO5XP9qNo2m9nAT82-EoDmv/s1600/01.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-fareast-language: IT; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirxnw6VzJDa-A8conMj0P17lfq0ZBZbJMKk5DzvUNeOeTnNMZ7cvcaDT5xDWpIU72N64YIq24KJf6_Ruce_hFXlT3na50ui6tCBk23wRiVFY98Z4HG14dJF_gPWoUikEpmb7hY0Yrv-BAm/s1600/02.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirxnw6VzJDa-A8conMj0P17lfq0ZBZbJMKk5DzvUNeOeTnNMZ7cvcaDT5xDWpIU72N64YIq24KJf6_Ruce_hFXlT3na50ui6tCBk23wRiVFY98Z4HG14dJF_gPWoUikEpmb7hY0Yrv-BAm/s1600/02.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Data table&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;This will be out data source. Now create a new ASP.NET application (or a MVC, &lt;/span&gt;&lt;span class=&quot;hps&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN;&quot;&gt;one or&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;shorttext&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;hps&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN;&quot;&gt;the other is&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;shorttext&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;hps&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN;&quot;&gt;indifferent).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;hps&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN;&quot;&gt;Add a new&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;ADO.NET Entity Data Model and add the previous database table to its designer. That’s result:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK4HReVNM-_nwjWOYOf8-jCIMDJRkg3GwQU3vd0s7RDnhyQuLrYXcytl3VE0tXwtnKq0Ez_VVzxnU6iE_KsqhA05p-tNch-v-IODw7lavZbcfPry7aGJWNhmMwJNLlsrac634rX6huUri-/s1600/03.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK4HReVNM-_nwjWOYOf8-jCIMDJRkg3GwQU3vd0s7RDnhyQuLrYXcytl3VE0tXwtnKq0Ez_VVzxnU6iE_KsqhA05p-tNch-v-IODw7lavZbcfPry7aGJWNhmMwJNLlsrac634rX6huUri-/s1600/03.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Entity&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;I saved my Entity Container Name as “DbTestEntities”. Normally, I prefer to create a new libray project and create a new ADO.NET Entity Model inside it, so I can reuse it in other applications. Remember our saved name because it will serve for the next step: WCF data service. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Now we see how to interact with data stored on a database and client-side components. I decided to use the DataService because they are easy to implement, and through the OData protocol can be queried directly from the URL when calling the service. Of course you can also use other traditional REST webservices, but in this example we’ll use a WCF Data Service.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;On Visual Studio 2010 project, add a new WCF Data Service. A new *.svc file will be created on our project. I saved it as “WcfDS.svc” Open this file and modify class code with parameters previous created in our entity model designer:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;public&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;WcfDS&lt;/span&gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;DataService&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DbTestEntities&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; InitializeService(&lt;span style=&quot;color: #2b91af;&quot;&gt;DataServiceConfiguration&lt;/span&gt; config)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;config.SetEntitySetAccessRule(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;T_STATE&quot;&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;EntitySetRights&lt;/span&gt;.AllRead);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;config.DataServiceBehavior.MaxProtocolVersion = &lt;span style=&quot;color: #2b91af;&quot;&gt;DataServiceProtocolVersion&lt;/span&gt;.V2;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;It’s important that DataService base class is of the type described on the entity container name. Remember, my previous name was “DbTestEntities”, so base class will be DataService&lt;dbtestentities&gt;.&lt;/dbtestentities&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;The other step is to set entity set access rule:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;config.SetEntitySetAccessRule(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;T_STATE&quot;&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;EntitySetRights&lt;/span&gt;.AllRead);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;First parameter will be the exact entity name (in my example it’s T_STATE) and right “AllRead”. These settings permit a read only permission in the table. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Press F5 to debug our project, navigate to our WCF Data Service Page (ex &lt;/span&gt;&lt;a href=&quot;http://localhost:1340/WcfDS.svc/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;http://localhost:1340/WcfDS.svc/&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;) and you can see something like this (it depend on used browser):&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;service xml:base=&quot;http://localhost:1340/WcfDS.svc/&quot;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;workspace&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;atom:title&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;Default&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/atom:title&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;collection href=&quot;T_STATE&quot;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;atom:title&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;T_STATE&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/atom:title&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/collection&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/workspace&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;/service&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Right! Now try to read T_STATE entity data through browser url &lt;/span&gt;&lt;a href=&quot;http://localhost:1340/WcfDS.svc/T_STATE&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;http://localhost:1340/WcfDS.svc/T_STATE&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt; and result source data will be something like this:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; standalone=&quot;yes&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;feed xml:base=&quot;http://localhost:1340/WcfDS.svc/&quot; xmlns:d=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices&quot; xmlns:m=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&quot; xmlns=&quot;http://www.w3.org/2005/Atom&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;title type=&quot;text&quot;&amp;gt;T_STATE&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;id&amp;gt;http://localhost:1340/WcfDS.svc/T_STATE&amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;updated&amp;gt;2012-07-31T20:29:12Z&amp;lt;/updated&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;link rel=&quot;self&quot; title=&quot;T_STATE&quot; href=&quot;T_STATE&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;entry&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id&amp;gt;http://localhost:1340/WcfDS.svc/T_STATE(1)&amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title type=&quot;text&quot;&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;updated&amp;gt;2012-07-31T20:29:12Z&amp;lt;/updated&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link rel=&quot;edit&quot; title=&quot;T_STATE&quot; href=&quot;T_STATE(1)&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;category term=&quot;DbTestModelNs.T_STATE&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;content type=&quot;application/xml&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:id m:type=&quot;Edm.Int32&quot;&amp;gt;1&amp;lt;/d:id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:State&amp;gt;ITALY&amp;lt;/d:State&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/content&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;entry&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id&amp;gt;http://localhost:1340/WcfDS.svc/T_STATE(2)&amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title type=&quot;text&quot;&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;updated&amp;gt;2012-07-31T20:29:12Z&amp;lt;/updated&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link rel=&quot;edit&quot; title=&quot;T_STATE&quot; href=&quot;T_STATE(2)&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;category term=&quot;DbTestModelNs.T_STATE&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;content type=&quot;application/xml&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:id m:type=&quot;Edm.Int32&quot;&amp;gt;2&amp;lt;/d:id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:State&amp;gt;USA&amp;lt;/d:State&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/content&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;entry&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id&amp;gt;http://localhost:1340/WcfDS.svc/T_STATE(3)&amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title type=&quot;text&quot;&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;updated&amp;gt;2012-07-31T20:29:12Z&amp;lt;/updated&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link rel=&quot;edit&quot; title=&quot;T_STATE&quot; href=&quot;T_STATE(3)&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;category term=&quot;DbTestModelNs.T_STATE&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;content type=&quot;application/xml&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:id m:type=&quot;Edm.Int32&quot;&amp;gt;3&amp;lt;/d:id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:State&amp;gt;GERMANY&amp;lt;/d:State&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/content&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;entry&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id&amp;gt;http://localhost:1340/WcfDS.svc/T_STATE(4)&amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title type=&quot;text&quot;&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;updated&amp;gt;2012-07-31T20:29:12Z&amp;lt;/updated&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link rel=&quot;edit&quot; title=&quot;T_STATE&quot; href=&quot;T_STATE(4)&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;category term=&quot;DbTestModelNs.T_STATE&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;content type=&quot;application/xml&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:id m:type=&quot;Edm.Int32&quot;&amp;gt;4&amp;lt;/d:id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:State&amp;gt;GREECE&amp;lt;/d:State&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/content&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;entry&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id&amp;gt;http://localhost:1340/WcfDS.svc/T_STATE(5)&amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title type=&quot;text&quot;&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;updated&amp;gt;2012-07-31T20:29:12Z&amp;lt;/updated&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/author&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link rel=&quot;edit&quot; title=&quot;T_STATE&quot; href=&quot;T_STATE(5)&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;category term=&quot;DbTestModelNs.T_STATE&quot; scheme=&quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;content type=&quot;application/xml&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:id m:type=&quot;Edm.Int32&quot;&amp;gt;5&amp;lt;/d:id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:State&amp;gt;FRANCE&amp;lt;/d:State&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/m:properties&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/content&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/entry&amp;gt;&lt;br /&gt;
&amp;lt;/feed&amp;gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-language: IT;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;You can get detailed information on this site OData protocol: &lt;/span&gt;&lt;a href=&quot;http://www.odata.org/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;http://www.odata.org/&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;If this is ok, we can proceed with the most interesting argument: how to read and use these data in a drop down list created by &lt;select&gt; html tag.&lt;/select&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;To do this, we need to download jQuery library and Knockout. We can found them here:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;a href=&quot;http://jquery.com/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;http://jquery.com/&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;a href=&quot;http://knockoutjs.com/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;http://knockoutjs.com/&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Then, as other library we need to reference these libraries in the html head tag. Suppose our path is in the script website directory, code will be following (in the example I use MVC 3 and Url helper):&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;script&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;&lt;/span&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Url.Content(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;~/Scripts/jquery-1.7.2.min.js&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;)&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;text/javascript&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;script&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;&lt;/span&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Url.Content(&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;~/Scripts&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;/&lt;span style=&quot;color: #741b47;&quot;&gt;knockout-2.1.0.js&lt;/span&gt;&quot;)&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;text/javascript&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US;&quot;&gt;We note that before we create a reference to the jQuery library, then Knockout. In this way we can ensure that any jQuery functions can be called and recognized with Knockuot. Now we can create JavaScript code to retrieve data and populate our drop down list (html select tag).&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; mso-ansi-language: EN-US;&quot;&gt;First we need to declare a class that represents our data. In this case, we need two fields: id and state name:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;function&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; StateDef(data) {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-indent: 35.4pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;this&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;.id = ko.observable(data.id);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none; text-indent: 35.4pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;this&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;.State = ko.observable(data.State);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Data parameter represent single data read from webservice. Now create a new ViewModel JavaScript function and bind it into Knockout library:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;function&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; StatesViewModel() {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;} &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;ko.applyBindings(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; StatesViewModel()); &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Here StatesViewModel code:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;function&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; StatesViewModel() {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; self = &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;self.states = ko.observableArray([]);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;self.selectedState = ko.observable();&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$.getJSON(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;../../WcfDS.svc/T_STATE&quot;&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; (res) {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; mappedStates = $.map(res.d, &lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; (item) { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; StateDef(item) });&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;self.states(mappedStates);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;})&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;.error(&lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; (err) { alert(err.responseText); });&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&lt;/span&gt;} &lt;span style=&quot;color: darkgreen;&quot;&gt;//end ViewModel&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;We create a new states variable and initialize it with an obserbableArray. The, with jQuery getJSON function we read all States data through WCF Data Service. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Note two things inside $.getJSON function: we use a $.map function to retrieve datas and “translate” them in the object we want, in this case transform them in our State definition (with StateDef function). Second thing is res.d variable. It represents data collection read from data&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;service, so “item” is a single state object.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;All of our mapped data will become our array of data to pass to select html control.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;That’s complete JavaScript code:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;script&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;text/javascript&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; StateDef(data) {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.id = ko.observable(data.id);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.State = ko.observable(data.State);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: darkgreen;&quot;&gt;// Overall viewmodel for this screen, along with initial state&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; StatesViewModel() {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; self = &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;self.states = ko.observableArray([]);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;self.selectedState = ko.observable();&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$.getJSON(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;../../WcfDS.svc/T_STATE&quot;&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; (res) {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; mappedStates = $.map(res.d, &lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; (item) { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; StateDef(item) });&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;self.states(mappedStates);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;})&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;.error(&lt;span style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; (err) { alert(err.responseText); });&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;} &lt;span style=&quot;color: darkgreen;&quot;&gt;//end ViewModel&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ko.applyBindings(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; StatesViewModel());&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;script&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;Last part consists of create our html select tag and bind it with Knockout data:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;select&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;data-bind&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;options: states, value: selectedState, optionsText: &#39;State&#39;&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;With “option” tag we connect previous states array. “value” is our selected item and “optionsText” represent our State description.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;In follow example I explain another kind to create a html select tag connected to Knockout data:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;select&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;data-bind&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;foreach: states&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;option&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;data-bind&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;text: State, value: id&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt;&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;In this example, I used a foreach iteration on states array. Then I create a single html option tag and bind it with id and State data.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;If we want to show select tag only if there are elements, we can add another parameter to data-bind select:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;select&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;data-bind&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;foreach: states, visible: states().length &amp;gt; 0&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;option&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;data-bind&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;text: State, value: id&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-family: Consolas; font-size: 9.5pt;&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;“Visible” in this case will be true only if exists at least one item in states array.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US;&quot;&gt;If you want to extend the use of Knockout and see all the potential, potetre go on the official website: &lt;a href=&quot;http://knockoutjs.com/&quot;&gt;http://knockoutjs.com/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/2010354466426526077/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2012/08/wcf-data-service-and-knockoutjs.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2010354466426526077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2010354466426526077'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2012/08/wcf-data-service-and-knockoutjs.html' title='WCF Data Service and Knockoutjs'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3WXNGmHCbAPiJiBMyRgtu2S1KVqChBqw6lQSHw2tknl5c1DbrGRdEkg94zuefKMCB8m6rN1SVRcliEDk2di7kVFReKzr3ucil7r6EpzfGSDPjCSEkz4ETYRO5XP9qNo2m9nAT82-EoDmv/s72-c/01.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-2576537468349779903</id><published>2012-07-09T22:12:00.000+02:00</published><updated>2012-07-09T22:12:07.681+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="earthquakes"/><category scheme="http://www.blogger.com/atom/ns#" term="terremoti"/><category scheme="http://www.blogger.com/atom/ns#" term="windows phone 7"/><title type='text'>Lista terremoti recenti</title><content type='html'>&lt;a href=&quot;http://www.windowsphone.com/it-IT/apps/ad03ceb0-86b4-4053-96d9-70b3fb6d5497&quot; target=&quot;_blank&quot;&gt;http://www.windowsphone.com/it-IT/apps/ad03ceb0-86b4-4053-96d9-70b3fb6d5497&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/2576537468349779903/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2012/07/lista-terremoti-recenti.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2576537468349779903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2576537468349779903'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2012/07/lista-terremoti-recenti.html' title='Lista terremoti recenti'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-8591628425926429755</id><published>2012-02-07T22:47:00.000+01:00</published><updated>2012-02-07T22:53:13.750+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="DTD"/><category scheme="http://www.blogger.com/atom/ns#" term="Linq to XML"/><category scheme="http://www.blogger.com/atom/ns#" term="xml"/><title type='text'>Ignore inline DTD in XML file with LINQ to XML</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;we want to read&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;an&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;XML&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;with LINQ to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;XML&lt;/span&gt; that have &lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;DTD&lt;/span&gt; inline &lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;instructions,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt; normally we &lt;/span&gt;&lt;span class=&quot;hps&quot;&gt;use this statement&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;hps&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; XDocument&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hps&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;doc =&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hps&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;XDocument.Load&lt;/span&gt;&lt;span class=&quot;hps atn&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;(&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;myXmlFile.xml&quot;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class=&quot;hps&quot;&gt;but... we&#39;ll receive&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;an exception&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt; &lt;span class=&quot;hps&quot;&gt;The&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;Load method&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;the XDocument&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;has&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;several overloads&lt;/span&gt;, &lt;span class=&quot;hps&quot;&gt;including&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;one&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;in particular that&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;takes as a parameter&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;an XmlReader object&lt;/span&gt;.&lt;br /&gt; &lt;span class=&quot;hps&quot;&gt;Let&#39;s see&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;how to use it&lt;/span&gt;&lt;span class=&quot;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; XmlReaderSettings settings = new XmlReaderSettings();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; settings.DtdProcessing = &lt;b&gt;DtdProcessing.Ignore&lt;/b&gt;;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; XmlReader reader = XmlReader.Create(&quot;myFile.xml&quot;, settings);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; XDocument doc = XDocument.Load(reader,&amp;nbsp;&amp;nbsp; LoadOptions.PreserveWhitespace);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;First, create a XmlReaderSettings object and set its DtdProcessing property to &quot;Ignore&quot;. It causes the DOCTYPE element to be ignored.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Then, create a new XmlReader object using the file path name &lt;/span&gt;&lt;/span&gt;and XmlReader &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;previously created &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;settings&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;Now we can open without previous exception out xml file, passing XmlReader object as argument of XDocument Load method.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/8591628425926429755/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2012/02/ignore-inline-dtd-in-xml-file-with-linq.html#comment-form' title='2 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/8591628425926429755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/8591628425926429755'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2012/02/ignore-inline-dtd-in-xml-file-with-linq.html' title='Ignore inline DTD in XML file with LINQ to XML'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-2022739075962643421</id><published>2012-01-16T23:31:00.000+01:00</published><updated>2012-01-16T23:31:54.363+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="entity framework"/><category scheme="http://www.blogger.com/atom/ns#" term="entitydatasource"/><category scheme="http://www.blogger.com/atom/ns#" term="isolation level"/><category scheme="http://www.blogger.com/atom/ns#" term="transactions"/><title type='text'>EntityDataSource and isolation level.</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;Suppose we have a&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;asp.net&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;display some&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;data from a&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;database table&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;in a&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;GridView&lt;/span&gt;&lt;span&gt;.&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;The latter is&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;connected&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;EntityDataSource&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;br /&gt; &lt;span class=&quot;hps&quot;&gt;If we&lt;/span&gt;&lt;span class=&quot;&quot;&gt; are running&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;a long elaboration&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;on that table&lt;/span&gt; &lt;span class=&quot;hps atn&quot;&gt;(&lt;/span&gt;&lt;span&gt;as an&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;update or&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;other processing&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;, the page&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;containing&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;the data to show&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;cannot&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;hang and&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;our data&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;until&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;processing&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;finished&lt;/span&gt;&lt;span class=&quot;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;That&#39;s not ever that we want....&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;Probably&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;this behavior is not&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;what we want&lt;/span&gt;&lt;span class=&quot;&quot;&gt;. &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;How can we&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;solve it&lt;/span&gt;&lt;span class=&quot;&quot;&gt;?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;Using &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;EntityDataSource &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;ContextCreated event&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt; we can &quot;attach&quot; a transaction to the ObjectContext used by datasource.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #0c343d; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;protected void MyEntityDataSource_ContextCreated(object sender, EntityDataSourceContextCreatedEventArgs e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Context.Connection.Open();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Context.Connection.BeginTransaction(IsolationLevel.ReadUncommitted);&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;First we have to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;manually open&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;the database connection.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt; Then, start a database transaction &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;specifying the isolation level we want to use. In this case, we need &quot;ReadUncommitted&quot; so we can read all data from database, including those not yet committed (dirty).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/2022739075962643421/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2012/01/entitydatasource-and-isolation-level.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2022739075962643421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/2022739075962643421'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2012/01/entitydatasource-and-isolation-level.html' title='EntityDataSource and isolation level.'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-7177800512896805622</id><published>2011-11-30T08:19:00.001+01:00</published><updated>2011-12-20T21:12:44.699+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="html5"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>Web data storage API HTML5</title><content type='html'>Look this tip (italian language only): &lt;br /&gt;
&lt;a href=&quot;http://www.html5italia.com/script/16/Web-Data-Storage-API-HTML5.aspx&quot; target=&quot;_blank&quot;&gt;Web data storage API HTML5 Look&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/7177800512896805622/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2011/11/web-data-storage-api-html5.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/7177800512896805622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/7177800512896805622'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2011/11/web-data-storage-api-html5.html' title='Web data storage API HTML5'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-3515558839357984268</id><published>2011-11-23T10:01:00.003+01:00</published><updated>2011-12-20T21:15:03.551+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="report"/><category scheme="http://www.blogger.com/atom/ns#" term="spire data export"/><title type='text'>Reportistica in ASP.NET con la libreria Spire.DataExport</title><content type='html'>Look this article (italian language only):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.aspitalia.com/articoli/asp.net/spire-dataexport-reporting.aspx&quot; target=&quot;_blank&quot;&gt;Reportistica in ASP.NET con la libreria Spire.DataExport&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/3515558839357984268/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2011/11/reportistica-in-aspnet-con-la-libreria.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/3515558839357984268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/3515558839357984268'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2011/11/reportistica-in-aspnet-con-la-libreria.html' title='Reportistica in ASP.NET con la libreria Spire.DataExport'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-4373690725390966093</id><published>2011-11-17T22:08:00.006+01:00</published><updated>2011-11-17T22:16:16.964+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="entity framework"/><category scheme="http://www.blogger.com/atom/ns#" term="objectquery"/><title type='text'>Trace T-SQL statements generated by Entity Framework</title><content type='html'>If we want to keep track of a query with Entity Framework without use a profiler, we can use the method ToTraceString which is part of the ObjectQuery object. In practice, this method displays the commands sent from our T-SQL query to the database.&lt;br /&gt;
&lt;br /&gt;
First, when using the ToTraceString method we need an open connection to the database, otherwise we will raise an exception. &lt;br /&gt;
&lt;br /&gt;
Its use is very simple. Here an example:&lt;br /&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-color: gray; border-style: solid; border-width: 1px; cursor: text; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; width: 97.5%;&quot;&gt;&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; (MyEntities ctx= &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt; MyEntities()) {&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;  var strSql = &lt;/span&gt;&lt;span style=&quot;color: #006080; font-size: small;&quot;&gt;&quot;SELECT VALUE t FROM MyEntities.&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Employees &lt;/span&gt;&lt;span style=&quot;color: #006080; font-size: small;&quot;&gt;AS t&quot;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;  var myQuery = ctx.CreateQuery&lt;employees&gt;(strSql);&lt;/employees&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;  ctx.Connection.Open();&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;  Console.WriteLine(myQuery.&lt;b&gt;ToTraceString()&lt;/b&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;  Console.ReadLine();&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas,&#39;Courier New&#39;,courier,monospace; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
The output will be something like:&lt;br /&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;[it].[FirstName] AS [FirstName],&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;[it].[LastName] AS &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;[LastName], &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;[it].[Age] AS &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;[Age]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: red;&quot;&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM [dbo].[Employees] AS [it] &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
One important thing about ToTraceString method is that it doesn’t execute the query but it&#39;s only output the statement to be executed.</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/4373690725390966093/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2011/11/trace-t-sql-statement-generated-by.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/4373690725390966093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/4373690725390966093'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2011/11/trace-t-sql-statement-generated-by.html' title='Trace T-SQL statements generated by Entity Framework'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-556530645912109068</id><published>2011-07-24T12:53:00.001+02:00</published><updated>2011-07-24T15:01:59.294+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="multiple file upload"/><title type='text'>Layout for multiple file upload with jQuery</title><content type='html'>&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;Within&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;forms,&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;many times&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;we need to&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;empower&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;users to enter&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;one or&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;more files&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;In some&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;cases&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;you&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;may need&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;to perform&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;the upload of&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;multiple files&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;without knowing&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;in advance&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;how&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;they might be.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;Limit the&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;number of inputs&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;for uploading&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;files&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;is sometimes not&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;the best choice&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;, so&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;we could&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;give the&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;user a chance to&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;put other&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;files in&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;his&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;complete autonomy&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;This post&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;explains&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;how to use&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;jQuery&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;without any&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;plugins&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;for creating&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;inserting multiple&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;fileupload&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;We start&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;from a simple&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;html page that&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;contains&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;only those elements&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;essential&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;for this application&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Multiupload file&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type=&quot;text/javascript&quot; src=&quot;Scripts/jquery-1.6.2.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type=&quot;text/javascript&quot; src=&quot;Scripts/JScript.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class=&quot;container&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button id=&quot;btAddFileUpload&quot; type=&quot;button&quot;&amp;gt;Add file&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div id=&quot;fileUp1&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input id=&quot;File1&quot; type=&quot;file&quot; /&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button id=&quot;btDelete1&quot; type=&quot;button&quot; value=&quot;1&quot; onclick=&quot;javascript:deleteUpload(value)&quot;&amp;gt;Delete&amp;lt;/button&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input id=&quot;Submit1&quot; type=&quot;submit&quot; value=&quot;Submit&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;I copied into my &quot;Scripts&quot; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;directory &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;latest jQuery library version, but you can refer it in the classic mode by Google:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;I wrote my JavaScript code in an external file called &quot;JScript.js&quot; and referenced in html script tag. This is the code:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;$(document).ready(function () {&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;#btAddFileUpload&#39;).click(add);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;});&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;//upload file tags counter&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;var count = 1;&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;//add fileupload method&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;function add() {&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //upload file tags increase&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count++;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //clone div tag with all children elements&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var copied = $(&#39;#fileUp1&#39;).clone(true);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //increase all children tags ids&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;input:file&#39;, copied).attr(&#39;id&#39;, &#39;File&#39; + count);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;button&#39;, copied).attr(&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { id: &#39;btDelete&#39; + count,&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value: count&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //increase div tag id&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(copied).attr(&#39;id&#39;, &#39;fileUp&#39; + count);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* another mode to change attribute names&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; copied.children(&#39;input&#39;).attr(&#39;id&#39;, &#39;File&#39; + count);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; copied.children(&#39;button&#39;).attr(&#39;id&#39;, &#39;btDelete&#39; + count);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //append copied div and relative children tags in container div, but before submit button&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(copied).appendTo(&#39;.container&#39;).insertBefore(&#39;#Submit1&#39;);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;//delete method fileupload method&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;function deleteUpload(id) {&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //remove file upload (parent div and childrens)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (count &amp;gt; 1) {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //decrease total amount of uploadfile tags&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count--;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var nameElemToDelete = &#39;#fileUp&#39; + id;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(nameElemToDelete).remove();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //to avoid holes, recalculating all the ids after the removed one&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (indx = id; indx &amp;lt;= count; indx++) {&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputDiv = $(&#39;#fileUp&#39; + (parseInt(indx) + 1));&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(inputDiv).attr(&#39;id&#39;, &#39;fileUp&#39; + indx);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;input:file&#39;, inputDiv).attr(&#39;id&#39;, &#39;File&#39; + indx);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;button&#39;, inputDiv).attr(&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { id: &#39;btDelete&#39; + indx,&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value: indx&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;At the begin, I call the $(document).ready jQuery statement to join the add function to add button at the startup (page entirely loaded).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;Each&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;time you click&lt;/span&gt; &lt;span class=&quot;hps atn&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;on the button &quot;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;btAddFileUpload&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;all&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;you clone&lt;/span&gt; &lt;span class=&quot;hps atn&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;the &quot;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;fileUp1&quot;&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;tag&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;including&lt;/span&gt; its &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;children, &lt;/span&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;renaming&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;id attributes with&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;a new name&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;including&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;the number&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;increases by one&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;All this is&lt;/span&gt; done &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;the jQuery methos&lt;/span&gt; &quot;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;clone&quot; on an &lt;/span&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;object (tag) that&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;you want to&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;replicate.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;With &quot;deleteUpload&quot; function you can delete the same tag (and all its childrens) and recalculate all ids to avoid holes. &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;This&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;was done to&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;iterate over&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;all the inputs&lt;/span&gt; file &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;without any problems&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;tag&quot;&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/556530645912109068/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2011/07/multiple-file-upload-with-jquery.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/556530645912109068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/556530645912109068'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2011/07/multiple-file-upload-with-jquery.html' title='Layout for multiple file upload with jQuery'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-1379012964805902988</id><published>2011-06-22T20:51:00.006+02:00</published><updated>2011-07-24T12:54:42.251+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="date"/><category scheme="http://www.blogger.com/atom/ns#" term="sql"/><title type='text'>C# - read range of dates without considering all holidays</title><content type='html'>&lt;div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The problem&lt;/span&gt;&lt;br /&gt;
I need to calculate the elapsed days between a date and the other, regardless of public holidays and national holidays.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The idea&lt;/b&gt;&lt;br /&gt;
The first thing to do was to remove from the range of dates on Saturdays and Sundays, in order to consider only working days.&lt;br /&gt;
For national holidays but I thought I&#39;d use a database table containing a list of dates as smalldatetime fields.&lt;br /&gt;
But I did not want every year to update all the dates of the table, only to set the new year. So I decided to set any date on the database with a fixed year 2011 (but I could also use more than one year &#39;recently).&lt;br /&gt;
The only date to be updated every year is the Easter holiday because it is considered a date &quot;variable&quot;.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;This is the table:&lt;/div&gt;&lt;div&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5621119904272678610&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKHHGaewhRQKGDdtmIHY-CqyOXMRzTZfmu4Gs-aUFmEuoopSHwInYZWCsOdpavZ7T2weQaQtoySRJqGdoWJxbdVSzxqCt8OMvQyHQSkgIcI1heevieWtcNmrbBPfyJ0GaMrU5ep322WMoW/s320/table.jpg&quot; style=&quot;cursor: hand; cursor: pointer; float: left; height: 261px; margin: 0 10px 10px 0; width: 165px;&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;My solution&lt;/b&gt;&lt;br /&gt;
Calculating the difference (in days) between the end date and the start and this would eliminate any other festive dates, according to Saturdays and Sundays and holidays are based on. However, if a holiday falls in one of these two days, obviously the date is eliminated once.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;This is the C# code:&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;public static int GetDateDiff(DateTime start, DateTime end) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;TimeSpan dsDiff = end - start;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int diff = dsDiff.Days;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int diff2 = diff;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (diff &amp;lt;= 0)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;             return diff;        &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;using (var ctx = new MyEntities()) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;run a&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;cycle on&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;any date&lt;/span&gt;&lt;span class=&quot;&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;from start to finish&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i = 0; i &amp;lt;= diff2; i++) {&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;DateTime dtTemp = start.AddDays(i);&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;//&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;cycle on&lt;/span&gt; &lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;any holiday date&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;hps&quot; title=&quot;Fai clic per visualizzare le traduzioni alternative&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;                 foreach (var t in ctx.T_HOLIDAYS) {&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;int yearDiff = t.date.Year - dtTemp.Year;  &lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TimeSpan ts = t.date - dtTemp.AddYears(yearDiff);&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;                        if (ts.Days == 0 &amp;amp;&amp;amp; t.date.DayOfWeek != DayOfWeek.Saturday &amp;amp;&amp;amp; t.date.DayOfWeek != DayOfWeek.Sunday) {&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;diff--;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;break;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;else if (dtTemp.DayOfWeek == DayOfWeek.Saturday || dtTemp.DayOfWeek == DayOfWeek.Sunday) {&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;diff--;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;break;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}//end foreach&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}//end for&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;}&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/1379012964805902988/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2011/06/c-read-range-of-dates-without.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/1379012964805902988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/1379012964805902988'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2011/06/c-read-range-of-dates-without.html' title='C# - read range of dates without considering all holidays'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKHHGaewhRQKGDdtmIHY-CqyOXMRzTZfmu4Gs-aUFmEuoopSHwInYZWCsOdpavZ7T2weQaQtoySRJqGdoWJxbdVSzxqCt8OMvQyHQSkgIcI1heevieWtcNmrbBPfyJ0GaMrU5ep322WMoW/s72-c/table.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3742387115082650335.post-3401627939353413352</id><published>2009-10-31T17:22:00.000+01:00</published><updated>2009-10-31T18:00:43.893+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="linq"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio 2008"/><title type='text'>Reading file with LINQ.</title><content type='html'>LINQ, the new extension in the Microsoft Framework 3.5 very often is very powerful. Today I tried to read a big txt file (104 Mbytes, 5 millions rows).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For first, I created a new Console application in C# .NET 3.5. In the main method i wrote this code:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;font-size:85%;&quot;  &gt;//start time&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;font-size:85%;&quot;  &gt;long start = Environment.TickCount;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;font-size:85%;&quot;  &gt;var query = from a in &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;File.ReadAllLines&lt;/span&gt;(@&quot;C:\reading_test.txt&quot;)&lt;br /&gt;                         select a;&lt;br /&gt;          foreach (string s in query)&lt;br /&gt;              ;&lt;br /&gt;&lt;br /&gt;          Console.WriteLine(&quot;With ReadAllLines: &quot; + (Environment.TickCount - start).ToString() + &quot; ms&quot;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When executed it on my machine, time result was  3313 ms.&lt;br /&gt;&lt;br /&gt;The File.ReadAllLines()  method sometimes is useful, but not performant. Infact with a line code only we can read all lines of a file. But there&#39;s a problem: if your input file is very big, you&#39;ll have a huge wast of memory.&lt;br /&gt;In my example, when this application start memory used was about 17Mb, but after the query was 360Mb !!&lt;br /&gt;This means all read lines are holdings in memory.&lt;br /&gt;&lt;br /&gt;I solved this problem in this way:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;long start = Environment.TickCount;&lt;br /&gt;          &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;using (StreamReader sr = new StreamReader(@&quot;C:\reading_test.txt&quot;))&lt;/span&gt; {&lt;br /&gt;              var query = from x in sr.&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;GetLines()&lt;/span&gt;&lt;br /&gt;                              select x;&lt;br /&gt;              foreach (string s in query)&lt;br /&gt;                  ;&lt;br /&gt;          }&lt;br /&gt;          Console.WriteLine(&quot;With Extension Method: &quot; + (Environment.TickCount - start).ToString() + &quot; ms&quot;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;This is my code for GetLines() extension method:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;static class ExtensionsClass {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;        public static IEnumerable&lt;string&gt; GetLines(this StreamReader sr) {            &lt;/string&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;            String line;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;            if(sr == null)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;                throw new ArgumentNullException();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;            while((line = sr.ReadLine()) != null)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;                yield return line;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;        }    &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;    }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;The query operator is implemented as an extension method for the StreamReader class. It enumerates the lines provided by the StreamReader one by one, but does not load a line in memory before it&#39;s actually needed.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);font-size:100%;&quot; &gt;The main point is that this technique allows you to work with huge files while maintaining a small memory usage profile.&lt;br /&gt;&lt;br /&gt;With first method (File.ReadAllLines) time elapsed was about 3600 ms. With the second (with extensin method) time elapsed was about 1200 (less than half of first).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://andriprogram.blogspot.com/feeds/3401627939353413352/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://andriprogram.blogspot.com/2009/10/reading-fiel-with-linq.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/3401627939353413352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3742387115082650335/posts/default/3401627939353413352'/><link rel='alternate' type='text/html' href='http://andriprogram.blogspot.com/2009/10/reading-fiel-with-linq.html' title='Reading file with LINQ.'/><author><name>Andrea</name><uri>http://www.blogger.com/profile/02427921776509950198</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>