<feed xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://www.w3.org/2005/Atom" xml:lang="it-IT">
    <title>Borsalino Moreno</title>
    <link rel="self" type="application/atom+xml" href="http://blogs.ugidotnet.org/BorsalinoMoreno/Atom.aspx" />
    <subtitle type="html">Riflessioni, opinioni, problemi e si spera soluzioni.</subtitle>
    <id>http://blogs.ugidotnet.org/BorsalinoMoreno/Default.aspx</id>
    <author>
        <name>Moreno Borsalino</name>
        <uri>http://blogs.ugidotnet.org/BorsalinoMoreno/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 2.1.0.3">Subtext</generator>
    <updated>2011-12-18T16:54:34Z</updated>
    <entry>
        <title>Quelli di Azure sono troppo avanti</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2011/12/18/quelli-di-azure-sono-troppo-avanti.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2011/12/18/quelli-di-azure-sono-troppo-avanti.aspx</id>
        <published>2011-12-18T16:54:34Z</published>
        <updated>2011-12-18T16:54:34Z</updated>
        <content type="html">&lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/8d83d8dab31e_ED0A/image_2.png" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/8d83d8dab31e_ED0A/image_thumb.png" width="703" height="173" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;tratto dalla pagina &lt;a href="http://www.windowsazure.com/it-it/develop/downloads/"&gt;http://www.windowsazure.com/it-it/develop/downloads/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/100633.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>IE9 bello ma &amp;hellip;</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2011/04/08/ie9-bello-ma-hellip.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2011/04/08/ie9-bello-ma-hellip.aspx</id>
        <published>2011-04-08T08:38:00Z</published>
        <updated>2011-04-08T08:38:00Z</updated>
        <content type="html">&lt;p&gt;Dopo molte peripezie sono riuscito ad installare un ie9 su un portatile touchscreen. Effettivamente IE9 e’ piu’ veloce ma l’interfaccia e’ peggiorata, con le icone cosi’ piccole non riesco piu’ ad usare il browser solo con le dita. Ma Ipad non ha insegnato niente ? E’ vero che Microsoft sui tablet si e’ storicamente fissata su quelli da usare con la penna ma sarebbe bello predisporre tutti gli applicativi di una doppia interfaccia per il mouse e le dita. Non dovremo mica aspettare Windows 8 per scoprire sta cosa ?&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99932.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>IE9 ed il mistero dei gadgets scomparsi</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2011/03/16/ie9-ed-il-mistero-dei-gadgets-scomparsi.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2011/03/16/ie9-ed-il-mistero-dei-gadgets-scomparsi.aspx</id>
        <published>2011-03-16T08:54:00Z</published>
        <updated>2011-03-16T08:54:00Z</updated>
        <content type="html">&lt;p&gt;Preso dall’emozione non ho saputo resistere ed ho installato IE9 su un pc con windows 7 su cui ho appena messo la SP1. Ho aspettato la versione finale di IE poiche’ non mi fido piu’ a provare cose in preview, ctp, beta, rc e simili. Installo e ….. I gadgets non funzionano piu’ &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-steamingmad" alt="Steaming mad" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/4b91d0006ede_7B8B/wlEmoticon-steamingmad_2.png" /&gt;. Restano neri o bianchi oppure ne appare solo un pezzettino e comunque non funzionano. Provato a toglierli e rimetterli, provato a reinstallarli ma niente di niente, tutto inutile. Alloro disinstallo IE9 e torno all’8 ma I gadgets restano sballati &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-steamingmad" alt="Steaming mad" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/4b91d0006ede_7B8B/wlEmoticon-steamingmad_2.png" /&gt;&lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-steamingmad" alt="Steaming mad" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/4b91d0006ede_7B8B/wlEmoticon-steamingmad_2.png" /&gt;&lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-steamingmad" alt="Steaming mad" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/4b91d0006ede_7B8B/wlEmoticon-steamingmad_2.png" /&gt;    &lt;br /&gt;Ora cerco su Google se qualche altra anima sfortunata ha qualche soluzione &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-cryingface" alt="Crying face" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/4b91d0006ede_7B8B/wlEmoticon-cryingface_2.png" /&gt;&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99837.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>Ipad</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/11/06/ipad.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/11/06/ipad.aspx</id>
        <published>2010-11-06T19:08:00Z</published>
        <updated>2010-11-06T19:08:00Z</updated>
        <content type="html">&lt;p&gt;Titolo ermetico per alcune riflessioni nate dopo una prova approfondita di un Ipad.&lt;/p&gt;  &lt;p&gt;Oggetto fantastico sotto tutti i punti di vista. Unico dubbio: ma ci voleva proprio Apple per tirarlo fuori e farne un successo ?    &lt;br /&gt;I concetti alla base di Ipad sono tutti fattibili con altre tecnologie e piattaforme anzi erano realizzabili da molto molto tempo ma nessuno ci ha creduto, nemmeno Microsoft. Già nel 2003 avevo provato dei tablet pc al Cebit e li consideravo molto interessanti se solo avessere avuto un’interfaccia meno computereccia e più “umana”. Ci sono voluti 7 anni per vedere quell’idea realizzata.     &lt;br /&gt;Microsoft con il multitouch su Windows 7 aveva in parte illuso ma il multitouch è scomparso fino a diventare qualcosa di nicchia, per fare scena. Già trovare un monitor multitouch è un’impresa, per non parlare dei tablet multitouch. Ne sto usando uno della Acer e le uniche applicazioni che ho trovato sono quelle del &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=b152fadd-82e4-4ddb-a46a-aebe49944428&amp;amp;displaylang=en"&gt;&lt;strong&gt;Microsoft Touch Pack for Windows 7&lt;/strong&gt;&lt;/a&gt;.     &lt;br /&gt;Per carità! Sono molto belle e sembra proprio di usare un Ipad. Ma ci si ferma li, non ce ne sono altre ne da parte di Microsoft ne di altri.     &lt;br /&gt;OK, direte che non vale la pena farle se poi pochissimi possono utilizzarle. Concordo, ma qui secondo me è colpa di un mercato lasciato a se stesso senza una guida forte. Per esempio, su Windows Phone 7 Microsoft impone restrizioni HW ben precise. Se avesse fatto lo stesso anche sul Windows 7 da tavolo imponendo per esempio uno schermo obbligatoriamente multitouch forse le cose sarebbero diverse (io avrei obbligato a mettere anche un gps, un g-sensor ed un modulo 3G ma è una mia fissa personale). Forse il fenomeno Ipad non sarebbe stato cosi’ tanto fenomeno. Forse ci sarebbero comunque migliaia di applicazioni per Ipad ma esisterebbe forse l’equivalente per Win7. Perchè i giornali si sono buttati a fare lettori di giornale per Ipad ed invece sul pc devo leggermi il giornale con il browser ? Eppure un’aplicazioncina wpf che fa scorrere un testo (magari col dito) non è fantascienza. Si,Ok, di Ipad ne vendono a milioni mentre di Win7 multitouch molto meno.&lt;/p&gt;  &lt;p&gt;Quello che Microsoft ha fatto molto bene è invece Surface, un oggetto fantastico ma … un po’ imgombrante. Forse se ne sono accorti e stanno calibrando il tiro. C’è un promettente tool in beta per realizzare applicazioni stile surface su un pc : &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;amp;FamilyID=801907a7-b2dd-4e63-9ff3-8a2e63932a74" target="_blank"&gt;Microsoft® Surface® Toolkit for Windows Touch Beta&lt;/a&gt; Vedremo che cosa succederà sul lungo termine. Anche un certo movimento dei costruttori verso I tablet sembra smuovere finalmente le acque. Si parla pero’ tanto di Android e poco di Windows 7. Peccato. Speriamo non diventi un’altra occasione perduta.&lt;/p&gt;  &lt;p&gt;Insomma tante parole per dire che ho messo fianco a fianco Ipad e Acer tablet e non vedo differenze se solo Acer avesse un’interfaccia alla Ipad e tante tante applicazioni quante ne ha Ipad. Forse dovrebbe essere Microsoft, visto il peso, a muoversi ed agitarsi in prima persona, ed invece niente. Si, ok, si agita su altri fronti ma su questo nulla, neanche una produzione di maggiori applicazioni per Win7 da usare col dito. OK, non chiedo un Visual studio per il dito ma almeno una versione di IE9 con UI finger-easy ? Una mappa da usare solo con le dita ? Un media player o un media center un po’ più ditoso ? Oppure ci sono ma non riesco a trovarli ?&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Pensieri pruriginosi da giorno di pioggia ? Mah …forse si.&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99451.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>Vinci 2000 $ con Open Kinect Project</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/11/06/vinci-2000-con-open-kinect-project.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/11/06/vinci-2000-con-open-kinect-project.aspx</id>
        <published>2010-11-06T17:35:00Z</published>
        <updated>2010-11-06T17:35:00Z</updated>
        <content type="html">&lt;p&gt;Tra pochi giorni Kinect sarà disponibile nei negozi. La publicità sui volantini già lo mostra e 149 Euro per l’oggetto del desiderio (non solo dei &lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/Vinci-2000_F1F5/image_2.png" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/Vinci-2000_F1F5/image_thumb.png" width="105" height="73" /&gt;&lt;/a&gt;bambini) alla portata di tutti…beh, avendo un Xbox ovviamente…o forse no ?&lt;/p&gt;  &lt;p&gt;Alcuni lo hanno già smontato e sezionato nelle più piccole parti : &lt;a href="http://www.ifixit.com/Teardown/Microsoft-Kinect-Teardown/4066/1" target="_blank"&gt;Microsoft Kinect Teardown&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ma la notizia che voglio segnalare è un premio di 2000 US $ offerto da Adafruit a chi per primo crea un driver open source per Kinect. Ed a quel punto non servirebbe piu’ Xbox &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-hotsmile" alt="Hot smile" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/Windows-Live-Writer/Vinci-2000_F1F5/wlEmoticon-hotsmile_2.png" /&gt;&lt;/p&gt;  &lt;p&gt;Il driver deve essere accompagnato da 2 applicazioni di test, una che mostra il video catturato dal sensore e una che mostra la distanza rilevata dal sensore.&lt;/p&gt;  &lt;h4&gt;&lt;a href="http://www.adafruit.com/blog/2010/11/04/the-open-kinect-project-the-ok-prize-get-1000-bounty-for-kinect-for-xbox-360-open-source-drivers/"&gt;The Open Kinect project – THE OK PRIZE – get $2,000 bounty for Kinect for Xbox 360 open source drivers (now $2k)&lt;/a&gt;&lt;/h4&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99447.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>Expression Encoder 4 Live Performance Tool</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/10/03/expression-encoder-4-live-performance-tool.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/10/03/expression-encoder-4-live-performance-tool.aspx</id>
        <published>2010-10-03T19:02:00Z</published>
        <updated>2010-10-03T19:02:00Z</updated>
        <content type="html">&lt;p&gt;Il  nuovo Expression Encoder 4 è un tool per la codifica di video anche di qualità HD ma richiede hw molto potente. Per testare se il nostro hw può farcela Microsoft offre un tool scaricabile qui :&lt;/p&gt;  &lt;h3&gt;&lt;font style="font-weight: normal"&gt;&lt;a href="http://gallery.expression.microsoft.com/en-us/EE4LivePerfTool" target="_blank"&gt;Expression Encoder 4 Live Performance Tool&lt;/a&gt;&lt;/font&gt;&lt;/h3&gt;  &lt;p&gt;Informazioni su come realizzare un sistema di smooth streaming live si puo’ trovare in quest’articolo:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/expressionencoder/archive/2010/09/22/10042763.aspx" target="_blank"&gt;Live IIS Smooth Streaming in Expression Encoder 4&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99292.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>JumpControl risolve il problema del reboot su W7 in remoto</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/09/02/jumpcontrol-risolve-il-problema-del-reboot-su-w7-in-remoto.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/09/02/jumpcontrol-risolve-il-problema-del-reboot-su-w7-in-remoto.aspx</id>
        <published>2010-09-02T16:21:00Z</published>
        <updated>2010-09-02T16:21:00Z</updated>
        <content type="html">&lt;p&gt;Con Windows 7 avevo il problema frequente di dover fare reboot o shutdown a computer via Remote Desktop. Purtroppo nel menu di start si puo’ fare solo LogOff o Lock. Mi ero organizzato usando dei comandi tipo: &lt;/p&gt;  &lt;p&gt;'shutdown -f -s -t 1' per lo shutdown    &lt;br /&gt;'shutdown -f -r -t 1' per il restart&lt;/p&gt;  &lt;p&gt;Poi su Channel 10 e’ uscito un articolo su &lt;a href="http://on10.net/blogs/sarahintampa/JumpControl-Adds-Shutdown-Options-to-Windows-7-Taskbar/"&gt;JumpControl&lt;/a&gt; che aggiunge un bottone nella taskbar che permette di fare Shutdown e Restart. Una meraviglia!&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99142.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>Quando il risveglio del Media Center &amp;egrave; sgradito</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/04/16/quando-il-risveglio-del-media-center-egrave-sgradito.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/04/16/quando-il-risveglio-del-media-center-egrave-sgradito.aspx</id>
        <published>2010-04-16T21:04:00Z</published>
        <updated>2010-04-16T21:04:00Z</updated>
        <content type="html">&lt;p&gt;Il Media Center è per me la versione piu’ piacevole per uso casalingo. Tuttavia ha uno sgradevole difetto. Il PC si risveglia per scaricare l’aggiornamento della guida TV e poi resta acceso. La cosa mi da veramente fastidio ma ancor di piu’ il fatto che disabilitare questo comportamento non è proprio facile. Mettere una riga tra i settings era troppo semplice ?&lt;/p&gt;  &lt;p&gt;La causa : il task mcupdate_scheduled risveglia il computer per scaricare la guida. L’ora di esecuzione è modificabile.&lt;/p&gt;  &lt;p&gt;La soluzione : disabilitare il risveglio del pc per eseguire il task.&lt;/p&gt;  &lt;p&gt;Ecco come. Aprire il Task Scheduler e cercare il task da modificare : &lt;/p&gt;  &lt;p&gt;Start &amp;gt; All Programs &amp;gt; Accessories &amp;gt; System Tools &amp;gt; Task Scheduler&lt;/p&gt;  &lt;p&gt;Nell’albero di sinistra aprire Task Scheduler Library &amp;gt; Microsoft &amp;gt; Windows &amp;gt; Media Center&lt;/p&gt;  &lt;p&gt;Nell’elenco dei Task nel pannello centrale cercare mcupdate_scheduled. Tasto destro del mouse per selezionare “Properties”. Selezionare il tab Conditions e quindi disabilitare il check "wake the computer to run this task".&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/WindowsLiveWriter/QuandoilrisvegliodelMediaCentersgradito_128A6/image_2.png" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.ugidotnet.org/images/blogs_ugidotnet_org/BorsalinoMoreno/WindowsLiveWriter/QuandoilrisvegliodelMediaCentersgradito_128A6/image_thumb.png" width="407" height="333" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3d27a7d4-e678-4be7-a63a-f0b548689594" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Media+Center" rel="tag"&gt;Media Center&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Windows+7" rel="tag"&gt;Windows 7&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/98383.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>Estrarre la product key di SQL Server</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/01/18/estrarre-la-product-key-di-sql-server.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/01/18/estrarre-la-product-key-di-sql-server.aspx</id>
        <published>2011-01-17T22:12:33Z</published>
        <updated>2011-01-18T19:42:36Z</updated>
        <content type="html">&lt;p&gt;Tempo fa avevo installato un server TFS 2010 di prova prendendo la versione di valutazione basata su un'immagine per Hyper-V già preinstallata. Adesso il periodo di valutazione è scaduto ma vorrei inserire delle chiavi regolari per renderlo operativo senza scadenze. Tutto fattibile tranne che per SQL Server. Infatti sia su MSDN che su volume license non viene fornita la product key ma solo installazione con chiave precablata.&lt;/p&gt;
&lt;p&gt;Ma per riattivare un'installazione di SQL Server 2008 scaduta c'è bisogno della chiave. Altrimenti bisogna reinstallare tutto.&lt;/p&gt;
&lt;p&gt;Bisogna lanciare "SQL Server Installation Center", fare click su Maintenance a sinistra e poi click su Edition Upgrade.&lt;br /&gt;
Cliccando un po' di volte su Next si arriva alla pagina Product Key in cui bisogna inserire la chiave. Ma dove prenderla ?&lt;/p&gt;
&lt;p&gt;Esistono dei programmi che dicono di essere capaci di estrarre la chiave usata nell'installazione ma mi sono salvato trovando un pezzettino di codice powershell che estrare la chiave e funziona perfettamente. L'ho verificato su Sql Server 2008 e 2008 R2.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR: rgb(204,0,0)"&gt;function Get-SQLserverKey {&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    ## function to retrieve the license key of a SQL 2008 Server.&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    ## by Jakob Bindslet (jakob@bindslet.dk)&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    param ($targets = ".")&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    $hklm = 2147483650&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    $regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup"&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    $regValue1 = "DigitalProductId"&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    $regValue2 = "PatchLevel"&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    $regValue3 = "Edition"&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    Foreach ($target in $targets) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $productKey = $null&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $win32os = $null&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $wmi = [WMIClass]"\\$target\root\default:stdRegProv"&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        [string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        [string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $binArray = ($data.uValue)[52..66]&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $charsArray = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        ## decrypt base24 encoded binary data&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        For ($i = 24; $i -ge 0; $i--) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;            $k = 0&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;            For ($j = 14; $j -ge 0; $j--) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;                $k = $k * 256 -bxor $binArray[$j]&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;                $binArray[$j] = [math]::truncate($k / 24)&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;                $k = $k % 24&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;         }&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;            $productKey = $charsArray[$k] + $productKey&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;            If (($i % 5 -eq 0) -and ($i -ne 0)) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;                $productKey = "-" + $productKey&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;            }&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        }&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $win32os = Get-WmiObject Win32_OperatingSystem -computer $target&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj = New-Object Object&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj | Add-Member Noteproperty Computer -value $target&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj | Add-Member Noteproperty OSCaption -value $win32os.Caption&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj | Add-Member Noteproperty SQLver -value $SQLver&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj | Add-Member Noteproperty SQLedition -value $SQLedition&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj | Add-Member Noteproperty ProductKey -value $productkey&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;        $obj&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;    }&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Per ottenere la chiave sul PC locale:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;Get-SQLserverKey&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Per ottenere la chiave da uno o piu' server remoti:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="COLOR: rgb(204,0,0)"&gt;Get-SQLserverKey "pc1", "pc2", "server999", "server777"&lt;/span&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Il codice proviene da questo post &lt;a href="http://mspowershell.blogspot.com/2010/11/sql-server-product-key.html"&gt;SQL Server Product Key&lt;/a&gt; di &lt;span class="fn"&gt;Jakob Bindslet.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="fn"&gt;Grazie Jakob !&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;br /&gt;
&lt;/p&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/99631.aspx" width="1" height="1" /&gt;</content>
    </entry>
    <entry>
        <title>[EF] QueryCompilate e MergeOption</title>
        <link rel="alternate" type="text/html" href="http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/01/17/ef-querycompilate-e-mergeoption.aspx" />
        <id>http://blogs.ugidotnet.org/BorsalinoMoreno/archive/2010/01/17/ef-querycompilate-e-mergeoption.aspx</id>
        <published>2010-01-17T20:49:00Z</published>
        <updated>2010-01-17T20:49:00Z</updated>
        <content type="html">&lt;p&gt;Per ottenere il massimo delle prestazioni quando si devono usare LINQ query è consigliato precompilarle e quando possibile usare anche l’opzione MergeOption.NoTracking. Quest’ultima evita di salvare le informazioni sulle modifiche degli oggetti nell’ObjectContext. E cosi’ ho fatto; ho compilate le query e le ho usate per leggere delle entità e modificarle. Ma ad un certo punto saltava fuori un errore sulla SaveChanges che non poteva essere eseguita poichè la query era stata compilata con l’opzione MergeOption.NoTracking.&lt;/p&gt;  &lt;p&gt;Vediamo cosa era successo. Consideriamo il seguente codice che compila una query che ritorna un utente data la email. Poi ci sono due metodi che usano questa query; una che legge solamente il nome dell’utente e quindi viene preceduto dal NoTracking ed un secondo metodo che scrive il nome dell’utente e quindi implicitamente è preceduta da AppendOnly, il valore di default di MergeOption . &lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; QueryCompiled &lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Func&amp;lt;MyEntities, &lt;span class="kwrd"&gt;string&lt;/span&gt;, IQueryable&amp;lt;Users&amp;gt;&amp;gt; GetUserByEmail = &lt;/pre&gt;

  &lt;pre&gt;            CompiledQuery.Compile&amp;lt;MyEntities, &lt;span class="kwrd"&gt;string&lt;/span&gt;, IQueryable&amp;lt;Users&amp;gt;&amp;gt;( &lt;/pre&gt;

  &lt;pre class="alt"&gt;                                             (MyEntities ctx, &lt;span class="kwrd"&gt;string&lt;/span&gt; email) =&amp;gt; &lt;/pre&gt;

  &lt;pre&gt;                                             from a &lt;span class="kwrd"&gt;in&lt;/span&gt; ctx.Users &lt;/pre&gt;

  &lt;pre class="alt"&gt;                                             &lt;span class="kwrd"&gt;where&lt;/span&gt; a.Email == email &lt;/pre&gt;

  &lt;pre&gt;                                             select a);&lt;/pre&gt;

  &lt;pre class="alt"&gt;}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; A&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetUserName(&lt;span class="kwrd"&gt;string&lt;/span&gt; email)&lt;/pre&gt;

  &lt;pre class="alt"&gt;  {&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (MyEntities context = &lt;span class="kwrd"&gt;new&lt;/span&gt; MyEntities()) &lt;/pre&gt;

  &lt;pre class="alt"&gt;    {&lt;/pre&gt;

  &lt;pre&gt;      context.Users.MergeOption = MergeOption.NoTracking; &lt;/pre&gt;

  &lt;pre class="alt"&gt;      var users= (QueryCompiled.GetUserByEmail(context, email)); &lt;/pre&gt;

  &lt;pre&gt;      &lt;span class="kwrd"&gt;return&lt;/span&gt; users.Name;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;  }&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetUserName(&lt;span class="kwrd"&gt;string&lt;/span&gt; email, &lt;span class="kwrd"&gt;string&lt;/span&gt; name)&lt;/pre&gt;

  &lt;pre&gt;  {&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (MyEntities context = &lt;span class="kwrd"&gt;new&lt;/span&gt; MyEntities()) &lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;      var users= (QueryCompiled.GetUserByEmail(context, email)); &lt;/pre&gt;

  &lt;pre&gt;      users.Name = name;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      context.SaveChanges();&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;  }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;Se l’ordine di esecuzione dei metodi della classe A è il seguente va tutto bene :&lt;/p&gt;

&lt;p&gt;A classeA = new A(); 
  &lt;br /&gt;classeA.SetUserName(&lt;a href="mailto:“aaa@aaa.aa"&gt;“aaa@aaa.aa&lt;/a&gt;”, “pippo”); 

  &lt;br /&gt;classeA.GetUserName(&lt;a href="mailto:“aaa@aaa.aa"&gt;“aaa@aaa.aa&lt;/a&gt;”);&lt;/p&gt;

&lt;p&gt;Se l’ordine di esecuzione si inverte, come nel seguente caso, allora ottengo l’errore che dicevo prima :&lt;/p&gt;

&lt;p&gt;A classeA = new A(); 
  &lt;br /&gt;classeA.GetUserName(&lt;a href="mailto:“aaa@aaa.aa"&gt;“aaa@aaa.aa&lt;/a&gt;”); 

  &lt;br /&gt;classeA.SetUserName(&lt;a href="mailto:“aaa@aaa.aa"&gt;“aaa@aaa.aa&lt;/a&gt;”, “pippo”);&lt;/p&gt;

&lt;p&gt;Il motivo è il seguente; quando la query compilata viene invocata la prima volta allora viene memorizzata in una chache una forma ottimizzata della query. Durante questa prima invocazione vengono memorizzate altre informazioni tra cui anche il tipo di MergeOption attivo nel momento dell’invocazione. Quest’ultimo è un particolare importante il cui dettaglio non avevo trovato nella documentazione ufficiale. Nel secondo caso indicato sopra succede che la prima volta viene invocata la query compilata con MergeOption.NoTracking e questo valore viene associato alla query compilata per cui quando dopo vado a richiamare la stessa query compilata per modificare un valore nel momento in cui si esegue SaveChanges la query fallisce perche’ risulta che è attivo il NoTracking. Notare che non cambia nulla se vado ad aggiungere un MergeOption.AppendOnly nel metodo SetUserName. Non cambia nulla anche se richiamo la query con un diverso ObjectContext; insomma, il MergeOption è associato indissolubilmente con la query compilata. 
  &lt;br /&gt;La soluzione è quella di duplicare la compilazione della query o meglio fare una compilazione separata per ogni valore della MergeOption che si intende usare. Purtroppo si ripeterebbe piu’ volte il codice della query LINQ. La soluzione ottimale è quella di usare un CompiledQueryReplicator che è una classe che permette di specificare la query LINQ una volta sola e automaticamente di compilare piu’ istanze della stessa. Le istanze vengono inserite in un Dictionary la cui Key è il tipo di MergeOption con cui si vuole compilare la query. L’idea è stata già esplicitata in questo progetto su CodePlex : &lt;a href="http://dcutilities.codeplex.com" target="_blank"&gt;http://dcutilities.codeplex.com&lt;/a&gt; e li si puo’ andare a recuperare le due classi CompiledQueryReplicator e EfCompiledQueryReplicatorFactory. Consiglio anche di leggere il &lt;a href="http://dcutilities.codeplex.com/wikipage?title=CompiledQueryReplicator%20Tutorial&amp;amp;ProjectName=dcutilities" target="_blank"&gt;tutorial&lt;/a&gt; per la spiegazione di come usarle. Di seguito riporto per semplicità il codice delle due classi. &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// The CompiledQueryReplicator is a class that allows you to specify a LINQ query once, then&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// automatically compile different instances of it. This is useful when you need multiple instances&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// of the same query compiled with different &amp;lt;see cref="System.Data.Objects.MergeOption"/&amp;gt;s, &lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// for example. Each instance is identified with a particular key of type &amp;lt;typeparamref name="TKey"/&amp;gt;.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;remarks&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;para&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// If you're using the Entity Framework (LINQ to Entities), it is suggested that you use the &lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;see cref="EfCompiledQueryReplicatorFactory{TKey}"/&amp;gt; class to instantiate instances of this&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// class, as it makes the syntax shorter and automatically provides you with the Entity Framework&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// compiled query compiler.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/para&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;para&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// This class is thread-safe.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/para&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TQuery"&amp;gt;The type of the query&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TKey"&amp;gt;The type to use as the key&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CompiledQueryReplicator&amp;lt;TQuery, TKey&amp;gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    {&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; Expression&amp;lt;TQuery&amp;gt; _QueryExpressionTree;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; Func&amp;lt;Expression&amp;lt;TQuery&amp;gt;, TQuery&amp;gt; _Compiler;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; IDictionary&amp;lt;TKey, TQuery&amp;gt; _CompiledQueries;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// Creates a CompiledQueryReplicator using the specified query that will be compiled with&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// the specified compiler.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="query"&amp;gt;The query's expression tree&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="compiler"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// A delegate that can compile the query expression tree into an actual query&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; CompiledQueryReplicator(Expression&amp;lt;TQuery&amp;gt; query, Func&amp;lt;Expression&amp;lt;TQuery&amp;gt;, TQuery&amp;gt; compiler)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            _QueryExpressionTree = query;&lt;/pre&gt;

  &lt;pre&gt;            _Compiler = compiler;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            _CompiledQueries = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;TKey, TQuery&amp;gt;();&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// Returns the compiled query instance associated with the specified key. If&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// no query instance has been created for the specified key, one will be&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// and it will be returned.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="key"&amp;gt;The key&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The compiled query.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; TQuery &lt;span class="kwrd"&gt;this&lt;/span&gt;[TKey key]&lt;/pre&gt;

  &lt;pre class="alt"&gt;        {&lt;/pre&gt;

  &lt;pre&gt;            get&lt;/pre&gt;

  &lt;pre class="alt"&gt;            {&lt;/pre&gt;

  &lt;pre&gt;                TQuery query;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;lock&lt;/span&gt; (_CompiledQueries)&lt;/pre&gt;

  &lt;pre&gt;                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (_CompiledQueries.ContainsKey(key) == &lt;span class="kwrd"&gt;false&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;                    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;                        query = _Compiler(_QueryExpressionTree);&lt;/pre&gt;

  &lt;pre&gt;                        _CompiledQueries.Add(key, query);&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    }&lt;/pre&gt;

  &lt;pre&gt;                    &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                        query = _CompiledQueries[key];&lt;/pre&gt;

  &lt;pre&gt;                }&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; query;&lt;/pre&gt;

  &lt;pre&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// Factory class that makes it easier to create &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// instances that hold LINQ to Entities compiled queries.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TKey"&amp;gt;T&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="rem"&gt;/// he type to use as the key for the CompiledQueryReplicators created&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EfCompiledQueryReplicatorFactory&amp;lt;TKey&amp;gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    {&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Creates a &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; that compiles LINQ to Entities&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// queries.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg0"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// The &amp;lt;see cref="ObjectContext"/&amp;gt; that encapsulates the model connection and metadata.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TResult"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// The type of the query results returned by executing the delegate returned by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="query"&amp;gt;The LINQ to Entities query expression to compile&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; created&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TResult&amp;gt;, TKey&amp;gt; Create&amp;lt;TArg0, TResult&amp;gt;(Expression&amp;lt;Func&amp;lt;TArg0, TResult&amp;gt;&amp;gt; query)&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;where&lt;/span&gt; TArg0 : ObjectContext&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TResult&amp;gt;, TKey&amp;gt;(query, CompiledQuery.Compile);&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// Creates a &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; that compiles LINQ to Entities&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// queries.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg0"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// The &amp;lt;see cref="ObjectContext"/&amp;gt; that encapsulates the model connection and metadata.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg1"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Represents the type of the parameter that has to be passed in when executing the delegate returned&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TResult"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// The type of the query results returned by executing the delegate returned by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="query"&amp;gt;The LINQ to Entities query expression to compile&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; created&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TArg1, TResult&amp;gt;, TKey&amp;gt; Create&amp;lt;TArg0, TArg1, TResult&amp;gt;(Expression&amp;lt;Func&amp;lt;TArg0, TArg1, TResult&amp;gt;&amp;gt; query)&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;where&lt;/span&gt; TArg0 : ObjectContext&lt;/pre&gt;

  &lt;pre class="alt"&gt;        {&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TArg1, TResult&amp;gt;, TKey&amp;gt;(query, CompiledQuery.Compile);&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Creates a &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; that compiles LINQ to Entities&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// queries.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg0"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// The &amp;lt;see cref="ObjectContext"/&amp;gt; that encapsulates the model connection and metadata.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg1"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// Represents the type of the parameter that has to be passed in when executing the delegate returned&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg2"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// Represents the type of the parameter that has to be passed in when executing the delegate returned&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TResult"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// The type of the query results returned by executing the delegate returned by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="query"&amp;gt;The LINQ to Entities query expression to compile&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; created&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TArg1, TArg2, TResult&amp;gt;, TKey&amp;gt; Create&amp;lt;TArg0, TArg1, TArg2, TResult&amp;gt;(Expression&amp;lt;Func&amp;lt;TArg0, TArg1, TArg2, TResult&amp;gt;&amp;gt; query)&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;where&lt;/span&gt; TArg0 : ObjectContext&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TArg1, TArg2, TResult&amp;gt;, TKey&amp;gt;(query, CompiledQuery.Compile);&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// Creates a &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; that compiles LINQ to Entities&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// queries.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg0"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// The &amp;lt;see cref="ObjectContext"/&amp;gt; that encapsulates the model connection and metadata.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg1"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Represents the type of the parameter that has to be passed in when executing the delegate returned&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg2"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Represents the type of the parameter that has to be passed in when executing the delegate returned&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TArg3"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// Represents the type of the parameter that has to be passed in when executing the delegate returned&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;typeparam name="TResult"&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// The type of the query results returned by executing the delegate returned by the Compile method.&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="query"&amp;gt;The LINQ to Entities query expression to compile&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The &amp;lt;see cref="CompiledQueryReplicator{TQuery,TKey}"/&amp;gt; created&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TArg1, TArg2, TArg3, TResult&amp;gt;, TKey&amp;gt; Create&amp;lt;TArg0, TArg1, TArg2, TArg3, TResult&amp;gt;(Expression&amp;lt;Func&amp;lt;TArg0, TArg1, TArg2, TArg3, TResult&amp;gt;&amp;gt; query)&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;where&lt;/span&gt; TArg0 : ObjectContext&lt;/pre&gt;

  &lt;pre class="alt"&gt;        {&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;TArg0, TArg1, TArg2, TArg3, TResult&amp;gt;, TKey&amp;gt;(query, CompiledQuery.Compile);&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Il codice di esempio riscritto con queste classi diventa :&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; QueryCompiled &lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; CompiledQueryReplicator&amp;lt;Func&amp;lt;MyEntities, &lt;span class="kwrd"&gt;string&lt;/span&gt;, Users&amp;gt;, MergeOption&amp;gt; &lt;/pre&gt;

  &lt;pre&gt;             GetUserByEmail = EfCompiledQueryReplicatorFactory&amp;lt;MergeOption&amp;gt;.Create( &lt;/pre&gt;

  &lt;pre class="alt"&gt;                                     (MyEntities ctx, &lt;span class="kwrd"&gt;string&lt;/span&gt; email) =&amp;gt; &lt;/pre&gt;

  &lt;pre&gt;                                     (from a &lt;span class="kwrd"&gt;in&lt;/span&gt; ctx.Users &lt;/pre&gt;

  &lt;pre class="alt"&gt;                                     &lt;span class="kwrd"&gt;where&lt;/span&gt; a.Email == email &lt;/pre&gt;

  &lt;pre&gt;                                     select a).FirstOrDefault());&lt;/pre&gt;

  &lt;pre class="alt"&gt;}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; A&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetUserName(&lt;span class="kwrd"&gt;string&lt;/span&gt; email)&lt;/pre&gt;

  &lt;pre class="alt"&gt;  {&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (MyEntities context = &lt;span class="kwrd"&gt;new&lt;/span&gt; MyEntities()) &lt;/pre&gt;

  &lt;pre class="alt"&gt;    {&lt;/pre&gt;

  &lt;pre&gt;      context.Users.MergeOption = MergeOption.NoTracking; &lt;/pre&gt;

  &lt;pre class="alt"&gt;      var users= (QueryCompiled.GetUserByEmail[MergeOption.NoTracking](context, email));&lt;/pre&gt;

  &lt;pre&gt;      &lt;span class="kwrd"&gt;return&lt;/span&gt; users.Name;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;  }&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetUserName(&lt;span class="kwrd"&gt;string&lt;/span&gt; email, &lt;span class="kwrd"&gt;string&lt;/span&gt; name)&lt;/pre&gt;

  &lt;pre&gt;  {&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (MyEntities context = &lt;span class="kwrd"&gt;new&lt;/span&gt; MyEntities()) &lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;      var users= (QueryCompiled.GetUserByEmail[MergeOption.AppendOnly](context, email)); &lt;/pre&gt;

  &lt;pre&gt;      users.Name = name;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      context.SaveChanges();&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;  }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;

&lt;p&gt;Da notare che nell’invocazione della query si specifica il tipo di MergeOption che si intende usare. Se esiste una query compilata con quell’opzione nel dizionario viene ritornata altrimenti ne viene creata una.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ef1c3fa5-7c58-4074-bd86-ecb4c60d9093" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Entity+Framework" rel="tag"&gt;Entity Framework&lt;/a&gt;,&lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CompiledQuery" rel="tag"&gt;CompiledQuery&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.ugidotnet.org/BorsalinoMoreno/aggbug/97878.aspx" width="1" height="1" /&gt;</content>
    </entry>
</feed>
