<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="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" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-9567658</atom:id><lastBuildDate>Fri, 20 Mar 2026 22:49:43 +0000</lastBuildDate><category>.NET</category><category>Tools</category><category>Ubuntu</category><category>Certification</category><category>Training</category><category>Database</category><category>Chinook Database</category><category>Patterns</category><category>VMware</category><category>Windows</category><category>.NET 4</category><category>ASP.NET MVC</category><category>EF4</category><category>Repository Factory</category><category>Subversion</category><category>Code Generation</category><category>GAT/GAX</category><category>Security</category><category>Silverlight</category><category>T4 Text Templates</category><category>Testing</category><category>WCSF</category><category>Dynamics CRM</category><category>PowerShell</category><category>SQL Server</category><category>SharePoint</category><category>TDD</category><category>Aspect Oriented Programming</category><category>DSL</category><category>Dapper</category><category>Git</category><category>Hardware</category><category>Java</category><category>Mac OS</category><category>Micro ISV</category><category>MySQL</category><category>NHibernate</category><category>ORM</category><category>Other</category><category>Personal</category><category>Programming</category><category>Skydrive</category><category>Spring Boot</category><category>Visual Studio 2010</category><category>WSS</category><category>WebForms</category><category>WinForms</category><category>jQuery</category><title>Luis Rocha&#39;s Blog</title><description></description><link>http://www.luisrocha.net/</link><managingEditor>noreply@blogger.com (Luis Rocha)</managingEditor><generator>Blogger</generator><openSearch:totalResults>93</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-4641065938267844016</guid><pubDate>Mon, 10 Oct 2016 04:21:00 +0000</pubDate><atom:updated>2021-06-25T00:20:58.983-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Spring Boot</category><title>Spring Boot Configuration Properties Localization</title><description>Spring Boot allows to &lt;a href=&quot;http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html&quot; target=&quot;_blank&quot;&gt;externalize application configuration&lt;/a&gt; by using properties files or YAML files. &lt;a href=&quot;http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html&quot; target=&quot;_blank&quot;&gt;Spring Profiles&lt;/a&gt;&amp;nbsp;provide a way to segregate parts of your application configuration and make it available in certain environments (development, qa, production, etc.).&lt;br /&gt;
&lt;br /&gt;
When building applications for multiple countries, you might have some configuration properties that might differ for a specific locale. One way to localize these configuration properties, would be creating a new profile per locale where you can override these values. This approach only works if your application is running for that specific locale, and not supporting multiple locales at the same time. This approach would also increase the number of profiles to be managed (number of application properties files).&lt;br /&gt;
&lt;br /&gt;
Here, I am going to show another approach where you can define the localizable properties inside your existing configuration properties class. For example, if have the following set of properties for a single country in your application.yml file:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;region:
  hostSuffix: .com
  currencyCode: USD
  patternShortDate: MM-dd-YYYY
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Then, you could localize these properties by defining them for specific locales, for example en_CA and en_GB:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;region:
  hostSuffix: .com
  currencyCode: USD
  patternShortDate: MM-dd-YYYY
  locales:
    en_CA:
      hostSuffix: .ca
      currencyCode: CAD
      patternShortDate: dd-MM-YYYY
    en_GB:
      hostSuffix: .co.uk
      currencyCode: GBD
      patternShortDate: dd-MM-YYYY
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
The idea is to be able to get the desired property by locale:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;// Getting a property for the default locale.
regionProperties.getHostSuffix(); // returns &quot;.com&quot;

// Getting a property for supported locales.
regionProperties.fromLocale(Locale.US).getHostSuffix(); // returns &quot;.com&quot;
regionProperties.fromLocale(Locale.CANADA).getHostSuffix(); // returns &quot;.ca&quot;
regionProperties.fromLocale(Locale.UK).getHostSuffix(); // returns &quot;.co.uk&quot;

// Getting a property for unsupported locales (returns the default)
regionProperties.fromLocale(Locale.ITALY).getHostSuffix(); // returns &quot;.com&quot; (default)
&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;
Mapping locale String to Locale object&lt;/h4&gt;
The first thing is to enable Spring to read the locale string, e.g. &quot;en_CA&quot;, and convert it to a &lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html&quot; target=&quot;_blank&quot;&gt;java.util.Locale&lt;/a&gt;&amp;nbsp;object while loading the application configuration properties. For that, we will need to define a Converter class from String to Locale by implementing the &lt;a href=&quot;https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/convert/converter/Converter.html&quot; target=&quot;_blank&quot;&gt;Converter&lt;/a&gt; interface and adding the &lt;a href=&quot;http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/context/properties/ConfigurationPropertiesBinding.html&quot; target=&quot;_blank&quot;&gt;@ConfigurationPropertiesBinding&lt;/a&gt; annotation to tell Spring to use it when biding the properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;@Component
@ConfigurationPropertiesBinding
public class LocaleConverter implements Converter&amp;lt;String, Locale&amp;gt; {

    private static final Map&amp;lt;String, Locale&amp;gt; LOCALE_MAP = new HashMap&amp;lt;&amp;gt;(Locale.getAvailableLocales().length);

    static {
        for (Locale locale : Locale.getAvailableLocales()) {
            LOCALE_MAP.put(locale.toString(), locale);
        }
    }

    @Override
    public Locale convert(String s) {
        return LOCALE_MAP.get(s);
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;
Loading the properties in your Configuration Proper&lt;/h4&gt;
Once added this converter, all you have to do in your configuration properties class is to add the following property with its public getter/setter and Spring loads the application.yml (or application.properties) files.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;    protected Map&amp;lt;String, Locale&amp;gt; locales = new HashMap&amp;lt;&amp;gt;();
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Lets define a generic abstract class with this property and with the method to find the setting by locale (fromLocale):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;public abstract class LocalizableProperties&amp;lt;T extends LocalizableProperties&amp;gt; {
    protected Locale locale;
    protected Map&amp;lt;String, Locale&amp;gt; locales = new HashMap&amp;lt;&amp;gt;();

    @PostConstruct
    private void postConstruct() {
        // Set the locale of each entry of the map.
        for (Map.Entry&amp;lt;String, Locale&amp;gt; entry : locales.entrySet()) {
            entry.getValue().setLocale(entry.getKey());
        }
    }

    public T fromLocale(Locale locale) {
        return locales.containsKey(locale) ? locales.get(locale) : (T) this;
    }

    public Locale getLocale() {
        return locale;
    }

    public void setLocale(Locale locale) {
        this.locale = locale;
    }

    public Map&amp;lt;String, Locale&amp;amp;gt getLocales() {
        return locales;
    }

    public void setLocales(Map&amp;lt;String, Locale&amp;amp;gt locales) {
        this.locales = locales;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;
Creating Localizable Configuration Properties&lt;/h4&gt;
Now, lets define our configuration properties class, RegionProperties, that simply extends our abstract class and define some application properties to be localized:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot; name=&quot;code&quot;&gt;&lt;code&gt;@Component
@ConfigurationProperties(prefix = &quot;region&quot;)
public class RegionProperties extends LocalizableProperties&amp;lt;RegionProperties&amp;gt; {
    private String hostSuffix;
    private String currencyCode;
    private String patternShortDate;

    public String getHostSuffix() {
        return hostSuffix;
    }

    public void setHostSuffix(String hostSuffix) {
        this.hostSuffix = hostSuffix;
    }

    public String getCurrencyCode() {
        return currencyCode;
    }

    public void setCurrencyCode(String currencyCode) {
        this.currencyCode = currencyCode;
    }

    public String getPatternShortDate() {
        return patternShortDate;
    }

    public void setPatternShortDate(String patternShortDate) {
        this.patternShortDate = patternShortDate;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
That is, any configuration property class that need to be localized can be declared to extend the LocaleProperties class so that it can be localizable.&lt;br /&gt;
&lt;br /&gt;
You can find a running code in my github repo:&lt;br /&gt;
&lt;a href=&quot;https://github.com/lerocha/spring-boot-localizable-properties&quot;&gt;https://github.com/lerocha/spring-boot-localizable-properties&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</description><link>http://www.luisrocha.net/2016/10/spring-boot-configuration-properties.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-8104708572589347475</guid><pubDate>Sun, 23 Aug 2015 23:56:00 +0000</pubDate><atom:updated>2021-06-25T00:17:48.140-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MySQL</category><title>Comparing MySQL databases with mysqldbcompare</title><description>If &amp;nbsp;you need to check the differences between two MySQL databases, you can use the mysqldbcompare utility. This utility is part of MySQL utilities and it is very useful when you want to check if databases from different environments (dev, testing, stage, production) are consistent. It compares the objects and data from two databases to find differences between them. The databases can be located on the same host or different hosts. This utility identifies objects having different definitions in the two databases and presents them in a diff-style format.&lt;br /&gt;
&lt;br /&gt;
To use mysqldbcompare, you will need to install MySQL Utilities and MySQL Connector/Python. You can find them here:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://dev.mysql.com/downloads/utilities/&quot;&gt;https://dev.mysql.com/downloads/utilities/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://dev.mysql.com/downloads/connector/python/&quot;&gt;http://dev.mysql.com/downloads/connector/python/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
I use&amp;nbsp;mysqldbcompare&amp;nbsp;to compare the database objects to identify new tables/columns or anything that has been&amp;nbsp;created or dropped. You can also use it to compare data itself, which would be useful to compare a replica or backup database with its source.&lt;br /&gt;
&lt;br /&gt;
The usage is very simple. I created two identical databases in my localhost using the &lt;a href=&quot;https://chinookdatabase.codeplex.com/&quot;&gt;Chinook Database&lt;/a&gt;&amp;nbsp;named Chinook and Chinook2.&lt;br /&gt;
&lt;br /&gt;
The mysqldbcompare syntax is very simple. You use &lt;i&gt;--server1&lt;/i&gt; and &lt;i&gt;server2&lt;/i&gt; to specify the hosts of the databases and then the database names between colon, for example &lt;i&gt;Chinook:Chinook2&lt;/i&gt;. You also can use &lt;i&gt;--run-all-tests&lt;/i&gt; to avoid stopping at the first object different, and continue to process for all db objects.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;&lt;code&gt;mysqldbcompare --server1=root:password@localhost:3306 --server2=root:password@localhost:3306 Chinook:Chinook2 --run-all-tests
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;&lt;code&gt;# server1 on localhost: ... connected.
# server2 on localhost: ... connected.
# Checking databases Chinook on server1 and Chinook2 on server2
#
# Object definitions differ. (--changes-for=server1)
#

--- `Chinook`
+++ `Chinook2`
@@ -1 +1 @@
-CREATE DATABASE `Chinook` /*!40100 DEFAULT CHARACTER SET latin1 */
+CREATE DATABASE `Chinook2` /*!40100 DEFAULT CHARACTER SET latin1 */

#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     Album                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Artist                                  pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Customer                                pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Employee                                pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Genre                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Invoice                                 pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     InvoiceLine                             pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     MediaType                               pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Playlist                                pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     PlaylistTrack                           pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     Track                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass   

# Databases are consistent.
#
# ...done
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Note that object definitions, row count and row content match. It shows that table checksum are different, but my guess is that they are not the exactly replica since I created Chinook2 by running the same sql script again.&lt;br /&gt;
&lt;br /&gt;
You can use the option&amp;nbsp;&lt;i&gt;--skip-data-check&lt;/i&gt; if you only want to compare objects definition and not data. After I made some changes in Chinook2 (drop and create table and columns), I run mysqldbcompare with &lt;i&gt;--skip-data-check&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;&lt;code&gt;mysqldbcompare --server1=root:password@localhost:3306 --server2=root:password@localhost:3306 Chinook:Chinook2 --run-all-tests --skip-data-check
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;&lt;code&gt;
# server1 on localhost: ... connected.
# server2 on localhost: ... connected.
# Checking databases Chinook on server1 and Chinook2 on server2
#
# Object definitions differ. (--changes-for=server1)
#

--- `Chinook`
+++ `Chinook2`
@@ -1 +1 @@
-CREATE DATABASE `Chinook` /*!40100 DEFAULT CHARACTER SET latin1 */
+CREATE DATABASE `Chinook2` /*!40100 DEFAULT CHARACTER SET latin1 */

# WARNING: Objects in server1.Chinook but not in server1.Chinook2:
#        TABLE: PlaylistTrack
#
# WARNING: Objects in server1.Chinook2 but not in server1.Chinook:
#        TABLE: Address
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     Album                                   pass    pass    SKIP    
# TABLE     Artist                                  pass    pass    SKIP    
# TABLE     Customer                                FAIL    pass    SKIP    
#
# Object definitions differ. (--changes-for=server1)
#

--- `Chinook`.`Customer`
+++ `Chinook2`.`Customer`
@@ -3,16 +3,14 @@
   `FirstName` varchar(40) CHARACTER SET utf8 NOT NULL,
   `LastName` varchar(20) CHARACTER SET utf8 NOT NULL,
   `Company` varchar(80) CHARACTER SET utf8 DEFAULT NULL,
-  `Address` varchar(70) CHARACTER SET utf8 DEFAULT NULL,
-  `City` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
-  `State` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
-  `Country` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
-  `PostalCode` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
   `Phone` varchar(24) CHARACTER SET utf8 DEFAULT NULL,
   `Fax` varchar(24) CHARACTER SET utf8 DEFAULT NULL,
   `Email` varchar(60) CHARACTER SET utf8 NOT NULL,
   `SupportRepId` int(11) DEFAULT NULL,
+  `AddressId` int(11) DEFAULT NULL,
   PRIMARY KEY (`CustomerId`),
   KEY `IFK_CustomerSupportRepId` (`SupportRepId`),
+  KEY `FK_CustomerAddressId` (`AddressId`),
+  CONSTRAINT `FK_CustomerAddressId` FOREIGN KEY (`AddressId`) REFERENCES `Address` (`AddressId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
   CONSTRAINT `FK_CustomerSupportRepId` FOREIGN KEY (`SupportRepId`) REFERENCES `Employee` (`EmployeeId`) ON DELETE NO ACTION ON UPDATE NO ACTION
 ) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=latin1

# TABLE     Employee                                FAIL    pass    SKIP    
#
# Object definitions differ. (--changes-for=server1)
#

--- `Chinook`.`Employee`
+++ `Chinook2`.`Employee`
@@ -6,15 +6,13 @@
   `ReportsTo` int(11) DEFAULT NULL,
   `BirthDate` datetime DEFAULT NULL,
   `HireDate` datetime DEFAULT NULL,
-  `Address` varchar(70) CHARACTER SET utf8 DEFAULT NULL,
-  `City` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
-  `State` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
-  `Country` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
-  `PostalCode` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
   `Phone` varchar(24) CHARACTER SET utf8 DEFAULT NULL,
   `Fax` varchar(24) CHARACTER SET utf8 DEFAULT NULL,
   `Email` varchar(60) CHARACTER SET utf8 DEFAULT NULL,
+  `AddressId` int(11) DEFAULT NULL,
   PRIMARY KEY (`EmployeeId`),
   KEY `IFK_EmployeeReportsTo` (`ReportsTo`),
+  KEY `FK_EmployeeAddressId` (`AddressId`),
+  CONSTRAINT `FK_EmployeeAddressId` FOREIGN KEY (`AddressId`) REFERENCES `Address` (`AddressId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
   CONSTRAINT `FK_EmployeeReportsTo` FOREIGN KEY (`ReportsTo`) REFERENCES `Employee` (`EmployeeId`) ON DELETE NO ACTION ON UPDATE NO ACTION
 ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1

# TABLE     Genre                                   pass    pass    SKIP    
# TABLE     Invoice                                 pass    pass    SKIP    
# TABLE     InvoiceLine                             pass    pass    SKIP    
# TABLE     MediaType                               pass    pass    SKIP    
# TABLE     Playlist                                pass    pass    SKIP    
# TABLE     Track                                   pass    pass    SKIP   

# Database consistency check failed.
#
# ...done
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
As you can see in the diff output above, I dropped the PlaylistTrack table and created the Address table (see # WARNING). I also dropped the address related columns in Employee and Customer tables (see lines starting with -) and added the addressId foreign key (see lines starting with +).&lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
&lt;a href=&quot;http://dev.mysql.com/doc/mysql-utilities/1.3/en/mysqldbcompare.html#option_mysqldbcompare_run-all-tests&quot;&gt;http://dev.mysql.com/doc/mysql-utilities/1.3/en/mysqldbcompare.html#option_mysqldbcompare_run-all-tests&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</description><link>http://www.luisrocha.net/2015/08/comparing-mysql-databases-with.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total><georss:featurename>Mountain View, CA 94043, USA</georss:featurename><georss:point>37.428434 -122.07238159999997</georss:point><georss:box>37.3275535 -122.23374309999997 37.529314500000005 -121.91102009999997</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-2757126478077611204</guid><pubDate>Mon, 03 Jun 2013 03:03:00 +0000</pubDate><atom:updated>2013-06-02T21:11:32.346-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Git</category><category domain="http://www.blogger.com/atom/ns#">Subversion</category><title>Converting a local Subversion repository to Git</title><description>There many articles there about converting a subversion repository to git, but I decided to write my article that describes the conversion of a simple subversion repository (trunk only) stored in the local file system. I have a couple of these repositories that I needed to convert to git and then push them to &lt;a href=&quot;http://bitbucket.org/&quot;&gt;bitbucket.org&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Note that you will still need svn installed in addition to git. If you are using Mac OSX, svn used to be installed by default but that changed in Mountain Lion (10.8). Since I have XCode already installed, I just went to &lt;i&gt;Xcode &amp;gt; Preferences &amp;gt; Downloads &amp;gt; Command Line Tools &amp;gt; Install&lt;/i&gt;. See details &lt;a href=&quot;http://blog.grapii.com/2012/08/svn-missing-in-mac-os-x-10-8-mountain-lion/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;b&gt;Create the Authors Mapping File&lt;/b&gt;&lt;/h2&gt;
The first step is to create a mapping file for the subversion users to the git users. With the help from &lt;a href=&quot;http://thomasrast.ch/git/git-svn-conversion.html&quot;&gt;here&lt;/a&gt;, I run the command below to create the initial mapping file. In my case, the local subversion repository is located at &lt;i&gt;//Users/lerocha/svn-repo&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;svn log file:///Users/lerocha/svn-repo | sed -ne &#39;s/^r[^|]*| \([^ ]*\) |.*$/\1 = \1 &amp;lt;\1@example.com&amp;gt;/p&#39; | sort -u &amp;gt; ~/authors.txt
&lt;/pre&gt;
&lt;br /&gt;
Open the generated file (~/authors.txt) in a text editor and change it from this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;lerocha = lerocha &amp;lt;lerocha@example.com&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
Into this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;lerocha = Luis Rocha &amp;lt;luis@luisrocha.net&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;
Convert to a local Git repository&lt;/h2&gt;
With the help from this &lt;a href=&quot;http://stackoverflow.com/questions/79165/how-to-migrate-svn-with-history-to-a-new-git-repository/79188#79188&quot;&gt;stackoverflow answer&lt;/a&gt;, run the following commands to initialize the local git repository and import the revisions from subversion:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;mkdir repo
cd repo
git svn init file:///Users/lerocha/svn-repo --no-metadata
git config svn.authorsfile ~/authors.txt
git svn fetch
&lt;/pre&gt;
&lt;br /&gt;
Your local git repository should contain all revisions from your local subversion.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Push to a remote repository&lt;/h2&gt;
Since we want to push it to&amp;nbsp;&lt;a href=&quot;http://bitbucket.org/&quot;&gt;bitbucket.org&lt;/a&gt;&amp;nbsp;(private repositories are free!), you first create an empty repository in&amp;nbsp;&lt;a href=&quot;http://bitbucket.org/&quot;&gt;bitbucket.org&lt;/a&gt;&amp;nbsp;and then run the following commands below to push to it:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;git remote add origin ssh://git@bitbucket.org/youruser/yourrepo.git
git push -u origin --all   # to push up the repo for the first time
&lt;/pre&gt;
&lt;br /&gt;</description><link>http://www.luisrocha.net/2013/06/converting-local-subversion-repository.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-2755770398807868710</guid><pubDate>Mon, 10 Dec 2012 04:59:00 +0000</pubDate><atom:updated>2012-12-09T21:59:57.711-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Chinook Database</category><category domain="http://www.blogger.com/atom/ns#">Database</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>Chinook Database is now available on NuGet</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Chinook sample database is now available on &lt;a href=&quot;https://nuget.org/packages?q=chinook&quot;&gt;NuGet&lt;/a&gt;. There are 3 packages available:&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Chinook Database SQL Scripts: contains the SQL scripts for all supported databases (SQL Server, SQL Server Compact Edition, SQLite, Oracle, MySQL, PostgreSQL, DB2 and EffiProz. In addition, it also contains batch files to run these scripts with the respective command prompt tools.&lt;/li&gt;
&lt;li&gt;Chinook Database for SQLite: contains a SQLite file with the Chinook database.&lt;/li&gt;
&lt;li&gt;Chinook Database for SQL Server Compact 4.0: contains a SQL Compact 4.0 file with the Chinook database.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
You can install the Chinook database within Visual Studio using the following &lt;a href=&quot;http://docs.nuget.org/docs/start-here/managing-nuget-packages-using-the-dialog&quot;&gt;instructions&lt;/a&gt;&amp;nbsp;and searching for &#39;Chinook&#39;:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&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/AVvXsEhBDTbLU8u16WJ198LCX1dTSuF4vZtywYQ6kdSe1whbtM0XUSeuGjBQVxRDQVqHsbOudvpxYbr-gjiY3tpSEnru9sQtWmuz8XIQRPaSCXOOntI62amipYFopqLDspzEkp2d3fLmpQ/s1600/nuget-chinook.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBDTbLU8u16WJ198LCX1dTSuF4vZtywYQ6kdSe1whbtM0XUSeuGjBQVxRDQVqHsbOudvpxYbr-gjiY3tpSEnru9sQtWmuz8XIQRPaSCXOOntI62amipYFopqLDspzEkp2d3fLmpQ/s1600/nuget-chinook.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
For now on, new releases will be available on Codeplex &lt;a href=&quot;http://chinookdatabase.codeplex.com/releases&quot;&gt;download page&lt;/a&gt; and also on Nuget.&lt;br /&gt;
&lt;br /&gt;
Enjoy!</description><link>http://www.luisrocha.net/2012/12/chinook-database-is-now-available-on.html</link><author>noreply@blogger.com (Luis Rocha)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBDTbLU8u16WJ198LCX1dTSuF4vZtywYQ6kdSe1whbtM0XUSeuGjBQVxRDQVqHsbOudvpxYbr-gjiY3tpSEnru9sQtWmuz8XIQRPaSCXOOntI62amipYFopqLDspzEkp2d3fLmpQ/s72-c/nuget-chinook.png" height="72" width="72"/><thr:total>1</thr:total><georss:featurename>Mountain View, CA 94040, USA</georss:featurename><georss:point>37.3785351 -122.086585</georss:point><georss:box>37.3280636 -122.165549 37.4290066 -122.007621</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-259225852953306840</guid><pubDate>Mon, 03 Dec 2012 05:24:00 +0000</pubDate><atom:updated>2012-12-02T22:24:49.329-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Chinook Database</category><category domain="http://www.blogger.com/atom/ns#">Database</category><title>Chinook Sample Database 1.4 Released</title><description>The &lt;a href=&quot;http://chinookdatabase.codeplex.com/&quot;&gt;Chinook Database&lt;/a&gt; is a sample database available for multiple database systems. It can be created by running a single SQL script. Chinook database is an alternative to the Northwind database, being ideal for demos and testing ORM tools targeting single and multiple database servers.
&lt;br /&gt;
&lt;br /&gt;
The Chinook Database represents a media store, including tables for artists, albums, media tracks, invoices and customers. The media information was generated from my iTunes library file, but anyone can download its source code and use their own iTunes library information. The sales information is auto-generated for a 4 years period. You can see the Chinook data model &lt;a href=&quot;http://chinookdatabase.codeplex.com/wikipage?title=Chinook_Schema&quot;&gt;here&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
This new version includes support for &lt;a href=&quot;http://www-01.ibm.com/software/data/db2/express/&quot;&gt;DB2&lt;/a&gt; and &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt;. Thanks to &lt;a href=&quot;https://twitter.com/brice_lambson&quot;&gt;@brice_lambson&lt;/a&gt; for implementing the PostgreSQL support! Chinook database is available for:
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;DB2 (new)&lt;/li&gt;
&lt;li&gt;EffiProz&lt;/li&gt;
&lt;li&gt;MySQL&lt;/li&gt;
&lt;li&gt;Oracle&lt;/li&gt;
&lt;li&gt;PostgreSQL (new)&lt;/li&gt;
&lt;li&gt;SQL Server&lt;/li&gt;
&lt;li&gt;SQL Server Compact&lt;/li&gt;
&lt;li&gt;SQLite&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
You can download the latest release from &lt;a href=&quot;http://chinookdatabase.codeplex.com/releases/view/55681&quot;&gt;here&lt;/a&gt;. There are available SQL scripts for each database system and also embedded database files for SQL Server Compact and SQLite.</description><link>http://www.luisrocha.net/2012/12/chinook-sample-database-14-released.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>2</thr:total><georss:featurename>Mountain View, CA 94040, USA</georss:featurename><georss:point>37.3785351 -122.086585</georss:point><georss:box>37.3280636 -122.165549 37.4290066 -122.007621</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-934803496736126220</guid><pubDate>Mon, 05 Mar 2012 07:16:00 +0000</pubDate><atom:updated>2012-03-05T00:23:22.499-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">EF4</category><category domain="http://www.blogger.com/atom/ns#">Testing</category><title>Unit Testing an Entity Framework Data Access Layer</title><description>&lt;div&gt;
One approach to write unit tests for a data access layer implemented using Entity Framework that targets SQL Server is to use a local test database SQL Server Compact Edition. The test database will have the same schema as the real application database, and it will contain the minimun necessary data for your test cases.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The only thing to keep in mind is that you will need to restore the previous state of the test database after each unit test run. There are multiple approaches such as to recreate the database before each test or simply restore a backup file. One approach that I like is to run the test under a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx&quot;&gt;TransactionScope&lt;/a&gt;. &amp;nbsp;In this approach, you create a &lt;b&gt;TransactionScope&lt;/b&gt; object before the test runs and call &lt;b&gt;TransactionScope.Dispose&lt;/b&gt; after the test is completed. Since &lt;b&gt;TransactionScope.Complete&lt;/b&gt; is not called, the Dispose method will rollback the changes. That is, you SQL Compact database will be back to the state before running the test.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you are using xUnit, then your unit test class will need to implement the IDisposable interface, create the TransactionScope in the constructor and dispose it in the Dispose method as shown below:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public class MyDataAccessUnitTests : IDisposable
{
  private TransactionScope _transactionScope;

  public MyDataAccessUnitTests()
  {
    _transactionScope = new TransactionScope();
  }

  [Fact]
  void Test1()
  {
    // TODO: implement it.
  }

  [Fact]
  void Test2()
  {
    // TODO: implement it.
  }

  public void Dispose()
  {
    _transactionScope.Dispose();
  }
}
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you are using NUnit or MSTest, then you can create and dispose the TransactionScope object in the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;8&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;xUnit&lt;/td&gt;
&lt;td&gt;NUnit&lt;/td&gt;
&lt;td&gt;MSTest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;new TransactionScope()&lt;/td&gt;
&lt;td&gt;Constructor&lt;/td&gt;
&lt;td&gt;[SetUp]&lt;/td&gt;
&lt;td&gt;[TestInitialize]&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TransactionScope.Dispose&lt;/td&gt;
&lt;td&gt;IDisposable.Dispose&lt;/td&gt;
&lt;td&gt;[TearDown]&lt;/td&gt;
&lt;td&gt;[TestCleanup]&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I hope this helps!&lt;/div&gt;</description><link>http://www.luisrocha.net/2012/03/unit-testing-entity-framework-data.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-3428369489138797536</guid><pubDate>Wed, 07 Dec 2011 06:30:00 +0000</pubDate><atom:updated>2011-12-07T01:04:33.114-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dapper</category><category domain="http://www.blogger.com/atom/ns#">EF4</category><category domain="http://www.blogger.com/atom/ns#">NHibernate</category><category domain="http://www.blogger.com/atom/ns#">ORM</category><title>Data Access Performance Comparison in .NET</title><description>When writing data access code you are probably using some sort of ORM or data mapper to make your life easier while retrieving and persisting data. We all know that this does not come for free, ORMs allow you to move faster, but there is always a performance hit. I recently started reading about &lt;a href=&quot;http://code.google.com/p/dapper-dot-net/&quot;&gt;Dapper .NET&lt;/a&gt;, an open-source, lightweight, single-file object mapper that was developed for the &lt;a href=&quot;http://stackoverflow.com/&quot;&gt;stackoverflow.com&lt;/a&gt; site to execute high performance queries. After seeing its amazing performance results on their project page, I decided to write my owns performance tests to compare it to other ORMs (Entity Framework, NHibernate), and also to plain ADO.NET code.&lt;br /&gt;
&lt;br /&gt;
For these tests, I am using the &lt;a href=&quot;http://chinookdatabase.codeplex.com/&quot;&gt;Chinook Database&lt;/a&gt; for SQL Server. I defined a simple repository interface and implemented it using different data access approaches. The interface implemented is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public interface IRepository
{
 Artist GetArtistById(int id);
 IEnumerable&amp;lt;Song&amp;gt; GetSongsByArtist(string name);
}
&lt;/pre&gt;
&lt;br /&gt;
The first method executes a simple query in a single table by the primary key. The second method executes a query in multiple tables using joins.&lt;br /&gt;
&lt;br /&gt;
There are multiple implementations of this repository interface including plain ADO.NET code with DataReaders, Entity Framework, NHibernate and Dapper .NET.

For the Entity Framework, there are four implementations: Linq To Entities, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb896297.aspx&quot;&gt;compiled Linq To Entities&lt;/a&gt;, native SQL query and stored procedures.

For NHibernate, there are implementations with HQL query, native SQL query, and stored procedure.&lt;br /&gt;
&lt;br /&gt;
All the code is available at &lt;a href=&quot;https://github.com/lerocha/DotNetDataAccessPerformance&quot;&gt;https://github.com/lerocha/DotNetDataAccessPerformance&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Single Table Query by Primary Key&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The first set of tests is to execute a simple query in a single table to get one record by the primary key. The SQL query is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;SELECT ArtistId, Name&amp;nbsp;FROM Artist&amp;nbsp;WHERE Artist.ArtistId=@id
&lt;/pre&gt;
&lt;br /&gt;
The following table contains the results per multiple runs:&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;1 run&lt;/td&gt;&lt;td&gt;10 runs&lt;/td&gt;&lt;td&gt;100 runs&lt;/td&gt;&lt;td&gt;500 runs&lt;/td&gt;&lt;td&gt;1000 runs&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DataReaderNativeQuery&lt;/td&gt;&lt;td&gt;0.0&lt;/td&gt;&lt;td&gt;2.0&lt;/td&gt;&lt;td&gt;24.9&lt;/td&gt;&lt;td&gt;134.1&lt;/td&gt;&lt;td&gt;264.4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DataReaderStoredProcedure&lt;/td&gt;&lt;td&gt;0.0&lt;/td&gt;&lt;td&gt;2.2&lt;/td&gt;&lt;td&gt;26.3&lt;/td&gt;&lt;td&gt;133.8&lt;/td&gt;&lt;td&gt;266.4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DapperNativeQuery&lt;/td&gt;&lt;td&gt;0.1&lt;/td&gt;&lt;td&gt;2.5&lt;/td&gt;&lt;td&gt;28.0&lt;/td&gt;&lt;td&gt;141.5&lt;/td&gt;&lt;td&gt;285.6&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DapperStoredProcedure&lt;/td&gt;&lt;td&gt;0.0&lt;/td&gt;&lt;td&gt;2.4&lt;/td&gt;&lt;td&gt;28.0&lt;/td&gt;&lt;td&gt;137.5&lt;/td&gt;&lt;td&gt;276.1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkCompiledLinqQuery&lt;/td&gt;&lt;td&gt;2.2&lt;/td&gt;&lt;td&gt;22.5&lt;/td&gt;&lt;td&gt;207.2&lt;/td&gt;&lt;td&gt;1041.0&lt;/td&gt;&lt;td&gt;2099.8&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkLinqToEntities&lt;/td&gt;&lt;td&gt;5.5&lt;/td&gt;&lt;td&gt;25.2&lt;/td&gt;&lt;td&gt;267.7&lt;/td&gt;&lt;td&gt;1263.6&lt;/td&gt;&lt;td&gt;2522.5&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkNativeQuery&lt;/td&gt;&lt;td&gt;0.7&lt;/td&gt;&lt;td&gt;8.2&lt;/td&gt;&lt;td&gt;85.2&lt;/td&gt;&lt;td&gt;426.0&lt;/td&gt;&lt;td&gt;859.5&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkStoredProcedure&lt;/td&gt;&lt;td&gt;1.4&lt;/td&gt;&lt;td&gt;5.2&lt;/td&gt;&lt;td&gt;58.3&lt;/td&gt;&lt;td&gt;275.8&lt;/td&gt;&lt;td&gt;552.8&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateHqlQuery&lt;/td&gt;&lt;td&gt;0.8&lt;/td&gt;&lt;td&gt;4.4&lt;/td&gt;&lt;td&gt;48.1&lt;/td&gt;&lt;td&gt;253.6&lt;/td&gt;&lt;td&gt;509.5&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateHqlQueryStrongType&lt;/td&gt;&lt;td&gt;0.1&lt;/td&gt;&lt;td&gt;4.1&lt;/td&gt;&lt;td&gt;47.2&lt;/td&gt;&lt;td&gt;251.4&lt;/td&gt;&lt;td&gt;508.7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateNativeQuery&lt;/td&gt;&lt;td&gt;1.1&lt;/td&gt;&lt;td&gt;4.4&lt;/td&gt;&lt;td&gt;46.1&lt;/td&gt;&lt;td&gt;256.9&lt;/td&gt;&lt;td&gt;490.1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateStoredProcedure&lt;/td&gt;&lt;td&gt;0.0&lt;/td&gt;&lt;td&gt;5.2&lt;/td&gt;&lt;td&gt;57.2&lt;/td&gt;&lt;td&gt;294.0&lt;/td&gt;&lt;td&gt;589.8&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
The 1-run test is executed twice, the first execution result is not shown since I am only considering hot start. The following chart shows the results of 1,000 runs. As you can see, using Entity Framework with Linq To Entities (non-compiled) has the worst performance result (2,552.5 ms). It gets a little bit better if you use EF compiled Linq query (2,099.8), then improvements starts when using EF with native query (859.5 ms). EF using stored procedure and all NHibernate approaches are way better, all around 500 ms. And finally, the performance of Dapper is very close to the plain ADO.NET code, providing an level of abstraction with minimal performance impact.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW4ZlaDSmvd84N9sAU6cHEI_3AK-MNLg1wWy80qBi9E4ZN4SX5hmGJJzd5ruh_SjRhw4E8sQgzNfwxHjAMIHwpkxVv7EtXybtr-RgKZQai0LA-aFUMhZE3wOFmHJ_SzTD2nOAi1w/s800/SingleTableQueryByPrimaryKey.png&quot; /&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Multiple Table Query with Joins&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The second test executes joins in multiple tables and filters by a non-key column. The SQL query is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt; SELECT Album.Title as AlbumName, 
 Track.Name as SongName, Artist.Name as ArtistName
 FROM Artist
 INNER JOIN Album ON Album.ArtistId = Artist.ArtistId
 INNER JOIN Track ON Track.AlbumId = Album.AlbumId
 WHERE Artist.Name=@name
&lt;/pre&gt;
&lt;br /&gt;
The following table contains the results per multiple runs:&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;1 run&lt;/td&gt;&lt;td&gt;10 runs&lt;/td&gt;&lt;td&gt;100 runs&lt;/td&gt;&lt;td&gt;500 runs&lt;/td&gt;&lt;td&gt;1000 runs&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DataReaderNativeQuery&lt;/td&gt;&lt;td&gt;0.0&lt;/td&gt;&lt;td&gt;5.9&lt;/td&gt;&lt;td&gt;63.0&lt;/td&gt;&lt;td&gt;321.8&lt;/td&gt;&lt;td&gt;644.2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DataReaderStoredProcedure&lt;/td&gt;&lt;td&gt;0.0&lt;/td&gt;&lt;td&gt;6.2&lt;/td&gt;&lt;td&gt;65.0&lt;/td&gt;&lt;td&gt;332.3&lt;/td&gt;&lt;td&gt;658.6&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DapperNativeQuery&lt;/td&gt;&lt;td&gt;0.4&lt;/td&gt;&lt;td&gt;6.4&lt;/td&gt;&lt;td&gt;68.0&lt;/td&gt;&lt;td&gt;346.1&lt;/td&gt;&lt;td&gt;685.5&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DapperStoredProcedure&lt;/td&gt;&lt;td&gt;0.1&lt;/td&gt;&lt;td&gt;6.7&lt;/td&gt;&lt;td&gt;67.2&lt;/td&gt;&lt;td&gt;342.3&lt;/td&gt;&lt;td&gt;679.7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkCompiledLinqQuery&lt;/td&gt;&lt;td&gt;1.0&lt;/td&gt;&lt;td&gt;9.9&lt;/td&gt;&lt;td&gt;103.3&lt;/td&gt;&lt;td&gt;525.6&lt;/td&gt;&lt;td&gt;1071.0&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkLinqToEntities&lt;/td&gt;&lt;td&gt;5.6&lt;/td&gt;&lt;td&gt;58.2&lt;/td&gt;&lt;td&gt;539.5&lt;/td&gt;&lt;td&gt;2699.9&lt;/td&gt;&lt;td&gt;5398.3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkNativeQuery&lt;/td&gt;&lt;td&gt;1.1&lt;/td&gt;&lt;td&gt;13.1&lt;/td&gt;&lt;td&gt;135.0&lt;/td&gt;&lt;td&gt;658.8&lt;/td&gt;&lt;td&gt;1328.3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;EntityFrameworkStoredProcedure&lt;/td&gt;&lt;td&gt;1.1&lt;/td&gt;&lt;td&gt;9.7&lt;/td&gt;&lt;td&gt;99.0&lt;/td&gt;&lt;td&gt;489.1&lt;/td&gt;&lt;td&gt;983.7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateHqlQuery&lt;/td&gt;&lt;td&gt;3.4&lt;/td&gt;&lt;td&gt;35.6&lt;/td&gt;&lt;td&gt;359.5&lt;/td&gt;&lt;td&gt;1806.2&lt;/td&gt;&lt;td&gt;3647.1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateHqlQueryStrongType&lt;/td&gt;&lt;td&gt;6.8&lt;/td&gt;&lt;td&gt;68.3&lt;/td&gt;&lt;td&gt;681.5&lt;/td&gt;&lt;td&gt;3430.0&lt;/td&gt;&lt;td&gt;6841.4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateNativeQuery&lt;/td&gt;&lt;td&gt;1.1&lt;/td&gt;&lt;td&gt;10.6&lt;/td&gt;&lt;td&gt;103.2&lt;/td&gt;&lt;td&gt;517.7&lt;/td&gt;&lt;td&gt;998.7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NHibernateStoredProcedure&lt;/td&gt;&lt;td&gt;0.8&lt;/td&gt;&lt;td&gt;10.1&lt;/td&gt;&lt;td&gt;102.0&lt;/td&gt;&lt;td&gt;516.2&lt;/td&gt;&lt;td&gt;1033.8&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
The following chart shows the results of 1,000 runs. As you can see,&amp;nbsp;the slowest implementation is NHibernate with strong type query, e.g. using NHibernate.IQuery.List&lt;t&gt;(), it took 6,841 ms. EF with LinqToEntities (non-compiled) is a little bit faster (5,398 ms). Using NHibernate without strong type query, e.g. using NHibernate.IQuery.List() is significant faster&amp;nbsp;(3,647 ms)&amp;nbsp;than its strong type equivalent (6,841 ms). Here, we can see the performance improvement when using EF compiled Linq queries (1,071 ms) in comparison with EF non compiled Linq To Entities (5,398 ms). The EF compiled Linq query implementation showed performance equivalent to EF with stored procedures, and NHibernate with native query and stored procedure.&amp;nbsp;And finally, the performance of Dapper (679-685 ms) is again very close to the plain ADO.NET code (644-658 ms), with minimal performance impact.&lt;/t&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlRANxw3keai8deBkoGZjLDD1SpfZTfYnxR9Ae0oMw-fgRMEWa8V0fTiY2gK36jQlx6m7mB2tzn_4HcPYx2W4AVizBIJi9PQ5tv9-VHF8ILcp6moEA_0L3640wBIsftaPUYc4Drg/s1600/MultipleTableQueryWithJoins.png&quot; /&gt;
&lt;/div&gt;
&lt;br /&gt;
The performance improvements using Dapper in comparison with Entity Framework and NHibernate is very significant. For database reads that need a high performance execution, you might consider using Dapper to get the best performance with some good abstraction from plain ADO.NET code.&lt;br /&gt;
&lt;br /&gt;
The source code of these tests is available at &lt;a href=&quot;https://github.com/lerocha/DotNetDataAccessPerformance&quot;&gt;github&lt;/a&gt; and I will continue to work on it to incorporate any feedback and also add additional tests for adding, deleting and updating records. Stay tunned!&lt;br /&gt;
&lt;br /&gt;</description><link>http://www.luisrocha.net/2011/12/data-access-performance-comparison-in.html</link><author>noreply@blogger.com (Luis Rocha)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW4ZlaDSmvd84N9sAU6cHEI_3AK-MNLg1wWy80qBi9E4ZN4SX5hmGJJzd5ruh_SjRhw4E8sQgzNfwxHjAMIHwpkxVv7EtXybtr-RgKZQai0LA-aFUMhZE3wOFmHJ_SzTD2nOAi1w/s72-c/SingleTableQueryByPrimaryKey.png" height="72" width="72"/><thr:total>6</thr:total><georss:featurename>Mountain View, CA 94040, USA</georss:featurename><georss:point>37.3785351 -122.086585</georss:point><georss:box>37.3280636 -122.165549 37.4290066 -122.007621</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-8675984302226215249</guid><pubDate>Wed, 12 Oct 2011 05:24:00 +0000</pubDate><atom:updated>2011-10-11T23:24:59.732-06:00</atom:updated><title>Using Powershell with Application Pools</title><description>While developing Web applications and services using IIS, you need to recycle the application once in a while. You could just run iisreset, but sometimes you only want to affect one specific application pool. If you are using IIS7 or later, you could use &lt;a href=&quot;http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/&quot;&gt;appcmd.exe&lt;/a&gt;, but if you have some legacy then one option would be powershell. For example, to recycle the ASP.NET 4 application pool using powershell, you can run:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;
# Recycle the ASP.NET 4 application pool
([ADSI] &quot;IIS://localhost/W3SVC/AppPools/ASP.NET v4.0&quot;).psbase.invoke(&quot;recycle&quot;)

# Stop the ASP.NET 4&amp;nbsp;application pool:
([ADSI] &quot;IIS://localhost/W3SVC/AppPools/ASP.NET v4.0&quot;).psbase.invoke(&quot;stop&quot;)

# Start the ASP.NET 4&amp;nbsp;application pool:
([ADSI] &quot;IIS://localhost/W3SVC/AppPools/ASP.NET v4.0&quot;).psbase.invoke(&quot;start&quot;)

# Verify the ASP.NET 4&amp;nbsp;application pool state: 1 = starting, 2 = started, 3 = stopping, 4 = stopped
([ADSI] &quot;IIS://localhost/W3SVC/AppPools/ASP.NET v4.0&quot;).AppPoolState
&lt;/pre&gt;
Enjoy!</description><link>http://www.luisrocha.net/2011/10/using-powershell-with-application-pools.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-3394461694012409960</guid><pubDate>Sun, 09 Oct 2011 07:04:00 +0000</pubDate><atom:updated>2011-10-11T23:02:59.785-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET 4</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET MVC</category><title>Avoiding MvcBuildViews build time impact in developers environment by using ASP.NET compiler as an external tool</title><description>&lt;br /&gt;
ASP.NET Razor views (.cshtml) and Web Form views (.aspx) are only compiled by the Web server when they are needed (runtime) and not by Visual Studio when you build your solution (build time).&amp;nbsp;The &lt;a href=&quot;http://haacked.com/archive/2011/05/09/compiling-mvc-views-in-a-build-environment.aspx&quot;&gt;MvcBuildViews&lt;/a&gt; option enables a post-build task (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms164291.aspx&quot;&gt;AspNetCompiler Task&lt;/a&gt;) to compile your ASP.NET views during build time, thus enabling you to catch syntax errors in the views earlier in the development process.&amp;nbsp;However, enabling MvcBuildViews can significantly increase your build time depending on the size of the Web project you are working on.&lt;br /&gt;
&lt;br /&gt;
To avoid the build time increase, you can enable MvcBuildViews in your build environment only (Release builds) and developers can use&amp;nbsp;the&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms229863(v=VS.100).aspx&quot;&gt;aspnet_compiler.exe&lt;/a&gt;&amp;nbsp;as an Visual Studio external tool to precompile ASP.NET views on demand instead of on every build to avoid the building time impact. This way, you will get the best of both worlds:&amp;nbsp;be able to compile views at build time, but not on every build, only when you need it.&lt;br /&gt;
&lt;br /&gt;
To enable MvcBuildViews in release builds only, you can follow the steps described &lt;a href=&quot;http://odetocode.com/Blogs/scott/archive/2011/02/16/notes-on-building-razor-views.aspx&quot;&gt;here&lt;/a&gt;. To use aspnet_compiler.exe as an external tool in Visual Studio:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Go to Visual Studio&amp;nbsp;&lt;b&gt;Tools&amp;nbsp;&lt;/b&gt;menu, and click on &lt;b&gt;External Tools&lt;/b&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Enter a title and consider adding a shortcut. I am using &lt;b&gt;Compile ASP.NET &amp;amp;Views&lt;/b&gt; and I just use the short cut ALT+T+V to run it.&lt;/li&gt;
&lt;li&gt;Enter the ASP.NET compiler command. For .NET 4, it is &lt;b&gt;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Add the following arguments: &lt;b&gt;-c -v temp -p $(ProjectDir)&lt;/b&gt;&amp;nbsp; - &amp;nbsp;(option &lt;b&gt;-c&lt;/b&gt; forces a full rebuild; option &lt;b&gt;-v&lt;/b&gt; defines the virtual path of the application to be compiled, if you use &lt;b&gt;temp&lt;/b&gt;, it will be in &lt;b&gt;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\temp&lt;/b&gt;; option &lt;b&gt;-p&lt;/b&gt; defines the physical path of the application to be compiled, by using&amp;nbsp;&lt;b&gt;$(ProjectDir)&lt;/b&gt;, it will compile the views of the current project in Visual Studio).&lt;/li&gt;
&lt;li&gt;Enter the initial directory:&amp;nbsp;&lt;b&gt;$(ProjectDir)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;I use the output window, which makes easier if you have errors and want to open the file with errors by double clicking on it.&lt;/li&gt;
&lt;li&gt;Press OK and you are all set. Just make sure to run this command when you are in your ASP.NET web project, or selecting or editing any of its files.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim7kbdx2O3e6y3RAkMclQpnTnalhVMSoK5tRIokSzzAKZvPStp59qvfgW8-4EoImdmkZRv1tMC0sVXjUjDAnSYSnBS_yQju_mgejA0Ril9AkiaUzHjtcJIquOZqanhS4KYo7lazg/s1600/Compile%252520ASP.NET%252520Views.png&quot; /&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Alternately, you could import the following registry key:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\External Tools\Compile ASP.NET &amp;amp;Views]
&quot;ToolCmd&quot;=&quot;C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\aspnet_compiler.exe&quot;
&quot;ToolDir&quot;=&quot;$(ProjectDir)&quot;
&quot;ToolArg&quot;=&quot;-c -v temp -p $(ProjectDir)&quot;
&quot;ToolOpt&quot;=dword:00000018&lt;/pre&gt;
&lt;br /&gt;
One advantage of using the aspnet_compiler.exe as external tool is to be able to continue work on Visual Studio 2010 while watching the results in the output window. This is way better than using MvcBuildViews in developers build since Visual Studio 2010 hangs and display that annoying message that it is busy.&lt;br /&gt;
&lt;br /&gt;
Happy building!</description><link>http://www.luisrocha.net/2011/10/avoiding-mvcbuildviews-build-time.html</link><author>noreply@blogger.com (Luis Rocha)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim7kbdx2O3e6y3RAkMclQpnTnalhVMSoK5tRIokSzzAKZvPStp59qvfgW8-4EoImdmkZRv1tMC0sVXjUjDAnSYSnBS_yQju_mgejA0Ril9AkiaUzHjtcJIquOZqanhS4KYo7lazg/s72-c/Compile%252520ASP.NET%252520Views.png" height="72" width="72"/><thr:total>2</thr:total><georss:featurename>Mountain View, CA, USA</georss:featurename><georss:point>37.3860517 -122.0838511</georss:point><georss:box>37.335585200000004 -122.1628151 37.4365182 -122.0048871</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-8679146222234605153</guid><pubDate>Wed, 24 Aug 2011 05:06:00 +0000</pubDate><atom:updated>2011-08-23T23:08:14.663-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET 4</category><category domain="http://www.blogger.com/atom/ns#">EF4</category><title>Managing Transactions with Entity Framework 4</title><description>The Entity Framework already supports native database transactions. When using the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb738822.aspx&quot;&gt;ObjectContext.SaveChanges&lt;/a&gt; method, it already operates within a database transaction. If any dirty &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.objects.objectstateentry.aspx&quot;&gt;ObjectStateEntry&lt;/a&gt; object cannot be persisted, then&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb738822.aspx&quot;&gt;ObjectContext.SaveChanges&lt;/a&gt;&amp;nbsp;will roll back the transaction and throw an exception. So, if you are working with only one object context then you have already built-in support for database transactions when using the&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb738822.aspx&quot;&gt;ObjectContext.SaveChanges&lt;/a&gt;&amp;nbsp;method.&lt;br /&gt;
&lt;br /&gt;
However, there are other complex scenarios where you want to&amp;nbsp;update a record in a database and add an entry to a message queue; or add, update, or delete records in different databases. In this situation, if you need these operations to be &lt;a href=&quot;http://en.wikipedia.org/wiki/ACID&quot;&gt;ACID&lt;/a&gt;, then you will need a distributed transaction that spans multiple databases and systems.&amp;nbsp;A distributed transaction is a kind of transaction that requires the enlistment of additional resource managers.&lt;br /&gt;
&lt;br /&gt;
If you have a complex persistence scenario as mentioned above, then you can use the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx&quot;&gt;TransactionScope&lt;/a&gt; class. This class uses the &lt;a href=&quot;http://technet.microsoft.com/en-us/library/cc774450(WS.10).aspx&quot;&gt;Microsoft Distributed Transaction Coordinator&lt;/a&gt; (MSDTC or DTC) which is a Windows service that coordinate transactions over different resource managers across multiple computers. Using MSDTC is an expensive task, however TransactionScope only uses&amp;nbsp;MSDTC&amp;nbsp;if it is necessary. If multiple instances of ObjectContext connect to the same database, then it uses a standard database transaction (SqlTransaction, OleDbTransaction). If there are multiple databases to be connected, then the transaction is promoted to MSDTC. If you are using SQL Server, transaction promotions in SQL Server 2008 happens less frequently than in SQL Server 2005, so SQL Server 2008 is more efficient in this matter. You can use the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms181091.aspx&quot;&gt;SQL Profiler&lt;/a&gt; tool to monitor how many transactions are promoted to MSDTC.&lt;br /&gt;
&lt;br /&gt;
When using&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx&quot;&gt;TransactionScope&lt;/a&gt;&amp;nbsp;with multiple instances of ObjectContext, you should not use the parameterless&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb336792.aspx&quot;&gt;ObjectContext.SaveChanges()&lt;/a&gt; method. Instead, you should use the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd395500.aspx&quot;&gt;ObjectContext.SaveChanges(SaveOptions)&lt;/a&gt; method and pass &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.objects.saveoptions.aspx&quot;&gt;SaveOptions.DetectChangesBeforeSave&lt;/a&gt;. The reason is to maintain the ObjectContext state if something fails, otherwise the&amp;nbsp;ObjectContext&amp;nbsp;will be in a bad state, i.e., thinking that the changes were successfully committed when they were actually rolled back. When all operations within the transaction are successfully completed, then you should call the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.complete.aspx&quot;&gt;TransactionScope.Complete&lt;/a&gt; method, and after that it is safe to call &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.acceptallchanges.aspx&quot;&gt;ObjectContext.AcceptAllChanges()&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Below you can see an example based on this &lt;a href=&quot;http://blogs.msdn.com/b/alexj/archive/2009/01/11/savechanges-false.aspx&quot;&gt;post&lt;/a&gt;,&amp;nbsp;but using the SaveChanges(SaveOptions) method instead of the obsolete &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb739065.aspx&quot;&gt;SaveOptions(Boolean)&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;using (TransactionScope scope = new TransactionScope())
{
    // Save changes but maintain context1 current state.
    context1.SaveChanges(SaveOptions.DetectChangesBeforeSave);

    // Save changes but maintain context2 current state.
    context2.SaveChanges(SaveOptions.DetectChangesBeforeSave);

    // Commit succeeded since we got here, then completes the transaction.
    scope.Complete();

    // Now it is safe to update context state.
    context1.AcceptAllChanges();
    context2.AcceptAllChanges();
}
&lt;/pre&gt;&lt;br /&gt;
That is, the example above updates two databases within a distributed transaction and ObjectContext instances are only updated if the transaction is successfully committed.&amp;nbsp;For an example of a transaction fail-retry scenario and using a database and a message queue, see the following link:&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb738523.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/bb738523.aspx&lt;/a&gt;</description><link>http://www.luisrocha.net/2011/08/managing-transactions-with-entity.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-6285831256941428639</guid><pubDate>Sun, 10 Apr 2011 02:00:00 +0000</pubDate><atom:updated>2011-04-09T20:00:53.320-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Extending the jQuery UI datepicker with new shortcuts</title><description>The jQuery UI &lt;a href=&quot;http://jqueryui.com/demos/datepicker/&quot;&gt;datepicker&lt;/a&gt;&amp;nbsp;has a set of default shortcuts to move to the next/previous month (PageDown/PageUp), to today&#39;s date (Ctrl+Home), etc.&amp;nbsp;After working with &lt;a href=&quot;http://quickbooks.intuit.com/&quot;&gt;QuickBooks&lt;/a&gt; for so long, I got used to the &lt;a href=&quot;http://support.quickbooks.intuit.com/support/pages/inproducthelp/core/qb2k8/contentpackage/core/miscellaneous/info_keyboard_shortcuts_dates.html&quot;&gt;QuickBooks date control shortcuts&lt;/a&gt;&amp;nbsp;that use letters instead of Ctrl+key combination like the jQuery UI datepicker. These shortcuts are very intuitive, e.g. the letter &lt;b&gt;W&lt;/b&gt; is used for the first day of the &lt;b&gt;W&lt;/b&gt;eek and the letter &lt;b&gt;K&lt;/b&gt; is used for the last day of the wee&lt;b&gt;K&lt;/b&gt;. Here, we will show how to extend the datepicker to support the additional shortcuts below.&lt;br /&gt;
&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;th&gt;Shortcut&lt;/th&gt;   &lt;th&gt;Description&lt;/th&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;+&lt;/td&gt;   &lt;td&gt;Next Day&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;-&lt;/td&gt;   &lt;td&gt;Previous Day&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;T&lt;/td&gt;   &lt;td&gt;&lt;b&gt;T&lt;/b&gt;oday&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;W&lt;/td&gt;   &lt;td&gt;First day of the &lt;b&gt;W&lt;/b&gt;eek&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;K&lt;/td&gt;   &lt;td&gt;Last day of the wee&lt;b&gt;K&lt;/b&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;M&lt;/td&gt;   &lt;td&gt;First day of the &lt;b&gt;M&lt;/b&gt;onth&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;H&lt;/td&gt;   &lt;td&gt;Last day of the mont&lt;b&gt;H&lt;/b&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;Y&lt;/td&gt;   &lt;td&gt;First day of the &lt;b&gt;Y&lt;/b&gt;ear&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td&gt;R&lt;/td&gt;   &lt;td&gt;Last day of the yea&lt;b&gt;R&lt;/b&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
The ideal solution would be to use the widget factory to subclass the datepicker and extend the &lt;i&gt;_doKeyPress&lt;/i&gt; function with the new shortcuts. However, the datepicker does not use the widget factory in jquery-ui 1.8, see more details &lt;a href=&quot;http://stackoverflow.com/questions/2526592/how-to-subclass-a-specific-jqueryui-widget-method&quot;&gt;here&lt;/a&gt;. The solution is to extend the datepicker with a new function &lt;i&gt;customKeyPress&lt;/i&gt;&amp;nbsp;and then bind it to the datepicker keypress event.&lt;br /&gt;
&lt;pre class=&quot;brush: javascript&quot; name=&quot;code&quot;&gt;/*!
 * Extensions for jQuery UI 1.8.7 datepicker
 *
 * Copyright 2011, Luis Rocha
 * Released under the MIT license.
 *
 */

// Extends datepicker with shortcuts for today, begin and end of the year and month.
$.extend($.datepicker, { customKeyPress: function (event) {
    var inst = $.datepicker._getInst(event.target);
    var c = String.fromCharCode(event.which).toLowerCase();
    switch (c) {
        case &quot;y&quot;:
            // First day of the (y)ear.
            if (inst.selectedDay == 1 &amp;&amp; inst.selectedMonth == 0) {
                // First day of previous year.
                $.datepicker._adjustDate(event.target, -12, &quot;M&quot;);
            } else if (inst.selectedMonth == 0) {
                // First day of the current year.
                $.datepicker._adjustDate(event.target, 1 - inst.selectedDay, &quot;D&quot;);
            } else {
                // First day of the current year.
                inst.selectedDay = 1;
                $.datepicker._adjustDate(event.target, -inst.selectedMonth, &quot;M&quot;);
            }
            break;
        case &quot;r&quot;:
            // Last day of the yea(r).
            if (inst.selectedDay == 31 &amp;&amp; inst.selectedMonth == 11) {
                // Last day of next year.
                $.datepicker._adjustDate(event.target, +12, &quot;M&quot;);
            } else if (inst.selectedMonth == 11) {
                // Last day of current year.
                $.datepicker._adjustDate(event.target, 31 - inst.selectedDay, &quot;D&quot;);
            } else {
                // Last day of current year.
                inst.selectedDay = 31;
                $.datepicker._adjustDate(event.target, 11 - inst.selectedMonth, &quot;M&quot;);
            }
            break;
        case &quot;m&quot;:
            // First day of the (m)onth.
            if (inst.selectedDay == 1) {
                $.datepicker._adjustDate(event.target, -1, &quot;M&quot;);
            } else {
                $.datepicker._adjustDate(event.target, 1 - inst.selectedDay, &quot;D&quot;);
            }
            break;
        case &quot;h&quot;:
            // Last day of the mont(h).
            var end = $.datepicker._getDaysInMonth(inst.selectedYear, inst.selectedMonth);
            if (inst.selectedDay == end) {
                var month = (inst.selectedMonth + 1) % 11;
                var year = inst.selectedYear + Math.floor((inst.selectedMonth + 1) / 11);
                inst.selectedDay = $.datepicker._getDaysInMonth(year, month);
                $.datepicker._adjustDate(event.target, +1, &quot;M&quot;);
            } else {
                $.datepicker._adjustDate(event.target, end - inst.selectedDay, &quot;D&quot;);
            }
            break;
        case &quot;w&quot;:
            // First day of the (w)eek.
            var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay);
            var offset = (date.getDay() &gt; 0 ? date.getDay() : 7);
            $.datepicker._adjustDate(event.target, -offset, &quot;D&quot;);
            break;
        case &quot;k&quot;:
            // Last day of the wee(k).
            var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay);
            var offset = (date.getDay() &lt; 6 ? 6 - date.getDay() : 7);
            $.datepicker._adjustDate(event.target, offset, &quot;D&quot;);
            break;
        case &quot;t&quot;:
            // Today (same as Ctrl+Home).
            $.datepicker._gotoToday(event.target);
            break;
        case &quot;+&quot;:
            // Increase day (same as Ctrl+Right).
            $.datepicker._adjustDate(event.target, +1, &#39;D&#39;);
            break;
        case &quot;-&quot;:
            // Decrease day (same as Ctrl+Left).
            $.datepicker._adjustDate(event.target, -1, &#39;D&#39;);
            break;
    }
}
});
&lt;/pre&gt;

The following code snippet shows how to bind the &lt;i&gt;customKeyPress&lt;/i&gt; function to the datepicker keypress:

&lt;pre class=&quot;brush: javascript&quot; name=&quot;code&quot;&gt;$(function() {
    $(&quot;#datepicker&quot;).datepicker().keypress(function (event) { 
        $.datepicker.customKeyPress(event);
    });
});
&lt;/pre&gt;
Once the datepicker is refactored to use the widget factory (maybe in jquery-ui 1.9??), I will update this code to use the widget factory solution instead. For future updates, see &lt;a href=&quot;https://github.com/lerocha/jquery-ui-extensions&quot;&gt;https://github.com/lerocha/jquery-ui-extensions&lt;/a&gt;.
&lt;br /&gt;
&lt;p&gt;A demo of this extended datepicker is available &lt;a href=&quot;http://dl.dropbox.com/u/7676834/jquery-ui-extensions/demo/default.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</description><link>http://www.luisrocha.net/2011/04/extending-jquery-ui-datepicker-with-new.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-3987356750818610736</guid><pubDate>Sat, 20 Nov 2010 08:13:00 +0000</pubDate><atom:updated>2011-08-30T17:02:43.664-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Chinook Database</category><category domain="http://www.blogger.com/atom/ns#">EF4</category><title>Creating Composite Keys using Code First with Entity Framework</title><description>&lt;b&gt;Update: For Entity Framework 4.1 RTM, the exception message is a little bit different. It suggests to use the ColumnAttribute instead of DataMemberAttribute. At the time of EF CTP 4, the Column attribute did not exist yet, so they were temporary using the DataMember attribute. I have updated this post to use Column attribute as the latest EF version.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I am starting using the &lt;a href=&quot;http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4announcement.aspx&quot;&gt;Entity Framework CTP 4&lt;/a&gt;, that includes &lt;a href=&quot;http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-in-the-entity-framework-and-code-first.aspx&quot;&gt;code first approach with data annotations&lt;/a&gt;.&lt;br /&gt;
When creating composite primary keys, you need specify the order of the primary keys, otherwise you will get an exception similar to:&lt;br /&gt;
&lt;pre&gt;System.InvalidOperationException : Unable to determine composite primary key ordering for type &#39;PlaylistTrack&#39;. Use the ColumnAttribute or the HasKey method to specify an order for composite primary keys.
&lt;/pre&gt;&lt;br /&gt;
As the exception message describes, one option is to use data annotations and add the Key and Column attributes to define the composite key as shown below:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public class PlaylistTrack
    {
        [Key, Column(Order=1)]
        public int PlaylistId { get; set; }

        [Key, Column(Order = 2)]
        public int TrackId { get; set; }

        [RelatedTo(ForeignKey = &quot;PlaylistId&quot;)]
        public Playlist Playlist { get; set; }

        [RelatedTo(ForeignKey = &quot;TrackId&quot;)]
        public Track Track { get; set; }
    }
&lt;/pre&gt;&lt;br /&gt;
Another option is to define the composite key using the HasKey method. In this option, the entity class will be:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public class PlaylistTrack
    {
        public int PlaylistId { get; set; }
        public int TrackId { get; set; }

        [RelatedTo(ForeignKey = &quot;PlaylistId&quot;)]
        public Playlist Playlist { get; set; }

        [RelatedTo(ForeignKey = &quot;TrackId&quot;)]
        public Track Track { get; set; }
    }
&lt;/pre&gt;&lt;br /&gt;
And the composite key is defined using the HasKey method when building the model:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;var builder = new ModelBuilder();

    //...

    builder.Entity&amp;lt;PlaylistTrack&amp;gt;().HasKey(p=&amp;gt;new {p.PlaylistId, p.TrackId});

    //...

    model = builder.CreateModel();
&lt;/pre&gt;&lt;br /&gt;
My personal choice is to use data annotations which were introduced since EF4 CTP3.</description><link>http://www.luisrocha.net/2010/11/creating-composite-keys-using-code.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-4655409980205210210</guid><pubDate>Tue, 16 Nov 2010 18:31:00 +0000</pubDate><atom:updated>2010-11-16T11:31:50.954-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Chinook Database</category><category domain="http://www.blogger.com/atom/ns#">Database</category><title>Chinook Sample Database 1.3 Released</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;The&amp;nbsp;&lt;a href=&quot;http://chinookdatabase.codeplex.com/&quot;&gt;Chinook Database&lt;/a&gt; is a sample database available for multiple database systems. It can be created by running a single SQL script. Chinook database is an alternative to the Northwind database, being ideal for demos and testing ORM tools targeting single and multiple database servers.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;The Chinook Database represents a media store,&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;span id=&quot;ctl00_ctl00_Content_TabContentPanel_Content_wikiSourceLabel&quot;&gt;including tables for artists, albums, media tracks, invoices and customers. The media information was generated from my iTunes library file, but anyone can download its source code and use their own iTunes library information. The sales information is auto-generated for a 4 years period.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;You can see the Chinook data model &lt;a href=&quot;http://chinookdatabase.codeplex.com/wikipage?title=Chinook_Schema&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;This new version includes support for&amp;nbsp;&lt;a href=&quot;http://www.sqlite.org/&quot;&gt;SQLite&lt;/a&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;and &lt;a href=&quot;http://effiproz.codeplex.com/&quot;&gt;EffiProz&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;. EffiProz is a cross-platform embedded database written entirely in C#. Chinook database is available for:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;EffiProz&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;MySQL&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;Oracle&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;SQL Server&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;SQL Server Compact&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;SQLite&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;You can download the latest release from&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;&lt;a href=&quot;http://chinookdatabase.codeplex.com/releases/&quot;&gt;here&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #30332d; font-family: &#39;Segoe UI&#39;, &#39;Microsoft Sans Serif&#39;, Arial, Geneva, sans-serif; font-size: 13px;&quot;&gt;. There are available SQL scripts for each database system and also embedded database files for SQL Server Compact and SQLite.&lt;/span&gt;&lt;/div&gt;</description><link>http://www.luisrocha.net/2010/11/chinook-sample-database-13-released.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-4619771090860102507</guid><pubDate>Tue, 21 Sep 2010 05:01:00 +0000</pubDate><atom:updated>2010-09-20T23:03:00.388-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Skydrive</category><category domain="http://www.blogger.com/atom/ns#">Windows</category><title>How to Map Skydrive as a Network Drive in Windows 7</title><description>There are already many posts about mapping &lt;a href=&quot;http://skydrive.live.com/&quot;&gt;Skydrive&lt;/a&gt; as a network drive in Windows and you are wondering why I am creating a new one. The reason is very simple, none of these existing posts worked for me. So,  I decided to put together all the information that worked for me, and  hopefully it can help someone else with the same problem.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Check Your Windows Environment&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
The first step is to make sure your Windows environment is ready for this mapping. I am  using Windows 7 x64, so I am not sure if this applies to other Windows  versions, but it does not hurt to check.&lt;br /&gt;
&lt;br /&gt;
1. WebClient Windows Service must be running as discussed &lt;a href=&quot;http://social.answers.microsoft.com/Forums/en-US/officewebapps/thread/dee336d9-6ef2-40c8-bd91-6d1900758b50&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Open the Services management console (Start / Run / &lt;b&gt;services.msc&lt;/b&gt;) and locate the &lt;b&gt;WebClient&lt;/b&gt; service.&lt;/li&gt;
&lt;li&gt;Start the &lt;b&gt;WebClient&lt;/b&gt; service if it is stopped.&lt;/li&gt;
&lt;li&gt;Open its &lt;b&gt;Properties&lt;/b&gt; window, and set the &lt;b&gt;Startup type&lt;/b&gt; to &lt;b&gt;Automatic&lt;/b&gt;.&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;Note: Although this service was already running for me, I still had to restart it and set it to automatic startup in order to be able to map Skydrive.&lt;br /&gt;
&lt;br /&gt;
2. Internet Explorer - LAN Settings should have Automatically detect settings unchecked&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Open Internet Explorer.&lt;/li&gt;
&lt;li&gt;Go to &lt;b&gt;Tools&lt;/b&gt;, &lt;b&gt;Internet Options&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Click on the &lt;b&gt;Connections&lt;/b&gt; tab, and click on the &lt;b&gt;LAN Settings&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Uncheck the &lt;b&gt;Automatically detect settings&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;Note: This might sound weird to check, but I also had to change this setting in order to make it work. When trying to map Skydrive using Windows  Explorer, it was asking for my Windows Live credentials multiple  times (about 3 times) until it fails. &lt;br /&gt;
&lt;ul&gt;&lt;/ul&gt;&lt;b&gt;Determine the WebDAV access address&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The second step is to determine the proper address (WebDAV access  address) you should use to connect to a Skydrive folder. You cannot  directly use the URL shown in your browser since it does not work. You will need to get the WebDAV  access address by using one of the following options: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Manually figure out the address based on the browser URL as described &lt;a href=&quot;http://mynetx.net/#%21/2352/how-to-connect-your-skydrive-in-windows-explorer&quot;&gt;here&lt;/a&gt;. I do not recommend this method since the folder name might be different than the one seen on the browser. For example, &lt;a href=&quot;http://mynetx.net/#%21/2352/how-to-connect-your-skydrive-in-windows-explorer&quot;&gt;here&lt;/a&gt; it mentions that &quot;Documents&quot; folder should be &quot;^2Documents&quot;, but for me it was &quot;^.Documents&quot;. &lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Use MS Office 2010 to save a document to Skydrive and then be able to see the WebDAV access address as described &lt;a href=&quot;http://www.addictivetips.com/microsoft-office/map-local-drive-letter-to-live-skydrive-using-office-2010/&quot;&gt;here&lt;/a&gt;. It would be a good option if you have this version of MS Office.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Build your own application that access &lt;a href=&quot;http://docs.live.net/SkyDocsService.svc&quot;&gt;http://docs.live.net/SkyDocsService.svc&lt;/a&gt; and query  for the WebDAV folders. It is good to know about this WCF service, but it will take  sometime to build a client application.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Use an existing application that uses the &lt;a href=&quot;http://docs.live.net/SkyDocsService.svc&quot;&gt;SkyDocsService&lt;/a&gt; and retrieve the information we need:  &lt;a href=&quot;http://skydrivesimpleviewer.codeplex.com/&quot;&gt;http://skydrivesimpleviewer.codeplex.com/&lt;/a&gt;. This open source project provides a command prompt  application &lt;b&gt;dumpurls.exe&lt;/b&gt; and also a WPF application  &lt;b&gt;SkyDriveSimpleViewer.exe&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;I decided to use the simplest way, e.g. the &lt;b&gt;dumpurls.exe&lt;/b&gt; command prompt  application. Download &lt;a href=&quot;http://skydrivesimpleviewer.codeplex.com/&quot;&gt;dumpurls.exe&lt;/a&gt;, and run it from a  Command Prompt window by passing your email (Windows Live or Hotmail) and  your password. If you are not confident about passing your credentials  to this application, you can temporary change your password in Windows  Live before running this application, and restore it after.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;DumpUrls.exe me@hotmail.com p4ssw0rd
&lt;/pre&gt;&lt;br /&gt;
The output is something like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;https://zzzzzz.docs.live.net/yyyyyyyyyyyyyyyy/^.Documents
https://xxxxxx.docs.live.net/yyyyyyyyyyyyyyyy/MyFolder
&lt;/pre&gt;&lt;br /&gt;
You will not use these URLs directly, but the corresponding paths instead:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;\\zzzzzz.docs.live.net@SSL\yyyyyyyyyyyyyyyy\^.Documents
\\xxxxxx.docs.live.net@SSL\yyyyyyyyyyyyyyyy\MyFolder
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Map Skydrive as Network Drive&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
Although you can map it by using Windows Explorer, I mapped using a single  command line in the Command Prompt window. So, open a Command Prompt  window and run the following command to map a folder named &lt;b&gt;MyFolder&lt;/b&gt; to the drive Z by using your credentials:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;net use Z: &quot;\\xxxxxx.docs.live.net@SSL\yyyyyyyyyyyyyyyy\MyFolder&quot; /user:me@hotmail.com p4ssw0rd /persistent:yes
&lt;/pre&gt;&lt;br /&gt;
The expected output is:&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;The command completed successfully.
&lt;/pre&gt;&lt;br /&gt;
Note: these are the errors I had before I fixed my Windows environment as explained in the beginning of this article:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;System error 5 has occurred&lt;/b&gt;: the solution for me was to change the IE setting described above.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;System error 1920 has occurred&lt;/b&gt;: the solution was to restart the WebClient service as described above.&lt;/li&gt;
&lt;/ul&gt;Now, you can just open Windows Explorer and start using your new drive on the cloud. I noticed that Windows Explorer does not report the proper used and free space, it might show that you have more than 25GB available.&lt;br /&gt;
&lt;ul&gt;&lt;/ul&gt;</description><link>http://www.luisrocha.net/2010/09/how-to-map-skydrive-as-network-drive-in.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-4921855474421251516</guid><pubDate>Sat, 18 Sep 2010 19:42:00 +0000</pubDate><atom:updated>2010-09-20T22:31:46.017-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET MVC</category><category domain="http://www.blogger.com/atom/ns#">Security</category><title>Microsoft ASP.NET Security Vulnerability: The &#39;Padding Oracle&#39; Attack</title><description>Early this week, a couple of security researchers, Juliano Rizzo and Thai Duong, have implemented an attack that exploits the way ASP.NET applications handle encrypted session cookies (see more details &lt;a href=&quot;http://threatpost.com/en_us/blogs/new-crypto-attack-affects-millions-aspnet-apps-091310&quot;&gt;here&lt;/a&gt;). They have discussed this in detail during the &lt;a href=&quot;http://ekoparty.org/juliano-rizzo-2010.php&quot;&gt;Ekoparty conference in Argentina&lt;/a&gt;. Their research paper is &lt;a href=&quot;http://usenix.org/events/woot10/tech/full_papers/Rizzo.pdf&quot;&gt;Practical Padding Oracle Attacks&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In the context of cryptography, an oracle is a system that provides hints as you ask it questions. And this attack explores a vulnerability in ASP.NET which acts as a padding oracle. This vulnerability is explained in details in &lt;a href=&quot;http://blogs.technet.com/b/srd/archive/2010/09/17/understanding-the-asp-net-vulnerability.aspx&quot;&gt;Understanding the ASP.NET Vulnerability.&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
This vulnerability allows attackers to have access to decrypt the information stored in the ViewState object. If sensitive information is stored there, such as passwords or database connection strings, then this data is compromised. If an ASP.NET application is using ASP.NET 3.5 SP1 or above, the attacker could use this encryption vulnerability to request the contents of an arbitrary file which the worker process has access to, for example, the &lt;b&gt;web.config&lt;/b&gt; file.&lt;br /&gt;
&lt;br /&gt;
Microsoft has released a security advisory about the problem: &lt;a href=&quot;http://www.microsoft.com/technet/security/advisory/2416728.mspx&quot;&gt;Microsoft Security Advisory (2416728)&lt;/a&gt;. If you or your clients have ASP.NET Web sites, then you must apply the necessary changes as described here:&lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx&quot;&gt; Scott Guthrie: ASP.NET Security Vulnerability&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update&lt;/b&gt;: Also take a look at &lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2010/09/20/frequently-asked-questions-about-the-asp-net-security-vulnerability.aspx&quot;&gt;Scott Guthrie&#39;s FAQ about AS.NET Security Vulnerability&lt;/a&gt;.</description><link>http://www.luisrocha.net/2010/09/microsoft-aspnet-security-vulnerability.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-5760096961806150232</guid><pubDate>Tue, 15 Jun 2010 00:43:00 +0000</pubDate><atom:updated>2010-06-14T18:46:35.221-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET MVC</category><title>JavaScript syntax error with telerik.grid.min.js</title><description>When implementing custom binding with the Telerik ASP.NET MVC, I based my code on this example described &lt;a href=&quot;http://demos.telerik.com/aspnet-mvc/grid/custombinding&quot;&gt;here&lt;/a&gt; under the &lt;i&gt;Controller&lt;/i&gt; tab. &lt;br /&gt;
&lt;br /&gt;
The &lt;b&gt;CustomBinding&lt;/b&gt; action is called when the whole page is loaded or refreshed, then showing on the grid the default data, e.g. the first page. This action should return a view with the model object (IEnumerable&amp;lt;Order&amp;gt; in this example).&lt;br /&gt;
&lt;br /&gt;
The &lt;b&gt;_CustomBinding&lt;/b&gt; action is called from an AJAX call when the user clicks on the grid controls, like page number, sort, or filter. This action &lt;b&gt;should return a view with a GridModel object and not with the view model&lt;/b&gt; (IEnumerable&amp;lt;Order&amp;gt;). If you do not use a GridModel object, then you will get the JavaScript syntax error char 4048 in telerik.grid.min.js.&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeIWDa_50t8IB1J3M7IcvTE7SYly9gXaU1tU8tXj6Q1jAz1Z-cDIs4XliRWqNhyAF0K1Yqn5FbZpPIE8XSSd7Bnlp-_4APMtCG9JPyeHIfep9QZ8jL9oiRwlCfp0FB1CjB6c40CA/&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Although the Telerik example is right, when I wrote my code based on it, I mistakenly used the wrong model object, and couldn&#39;t figure out what was wrong. Thanks for this forum &lt;a href=&quot;http://www.telerik.com/community/forums/aspnet-mvc/grid/telerik-grid-min-js-syntax-error-when-trying-to-filter.aspx&quot;&gt;post&lt;/a&gt; that enlighted me of what was going on.</description><link>http://www.luisrocha.net/2010/06/javascript-syntax-error-with.html</link><author>noreply@blogger.com (Luis Rocha)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeIWDa_50t8IB1J3M7IcvTE7SYly9gXaU1tU8tXj6Q1jAz1Z-cDIs4XliRWqNhyAF0K1Yqn5FbZpPIE8XSSd7Bnlp-_4APMtCG9JPyeHIfep9QZ8jL9oiRwlCfp0FB1CjB6c40CA/s72-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-5918097384598393889</guid><pubDate>Sat, 12 Jun 2010 07:00:00 +0000</pubDate><atom:updated>2010-06-12T01:00:09.098-06:00</atom:updated><title>Using SyntaxHighlighter (version 2.1.364) with Blogger</title><description>After spending sometime to make &lt;a href=&quot;http://alexgorbatchev.com/wiki/SyntaxHighlighter&quot;&gt;SyntaxHighlighter&lt;/a&gt; work with Blogger, I finally found an article that has the solution that perfectly worked for me. The other posts I found were not using the latest version (version 2.1.364 when this post was published), so no support for latest languages such as PowerShell, or they were using the latest version but the instructions didn&#39;t  work 100%.The following article worked for me:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://geektalkin.blogspot.com/2009/11/embed-code-syntax-highlighting-in-blog.html&quot;&gt;http://geektalkin.blogspot.com/2009/11/embed-code-syntax-highlighting-in-blog.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><link>http://www.luisrocha.net/2010/06/using-syntaxhighlighter-version-21364.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-8115850221862385081</guid><pubDate>Wed, 09 Jun 2010 14:45:00 +0000</pubDate><atom:updated>2010-06-12T00:18:40.594-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PowerShell</category><title>Checking the type and size of RAM with Windows PowerShell</title><description>I subscribe to the PowerTip of the day email of &lt;a href=&quot;http://powershell.com/&quot;&gt;PowerShell.com&lt;/a&gt; and I got this tip today. If you want to know the type and size of RAM your PC uses, and available banks, you can use the following script:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;$memorytype = &quot;Unknown&quot;, &quot;Other&quot;, &quot;DRAM&quot;, &quot;Synchronous DRAM&quot;, &quot;Cache DRAM&quot;,
&quot;EDO&quot;, &quot;EDRAM&quot;, &quot;VRAM&quot;, &quot;SRAM&quot;, &quot;RAM&quot;, &quot;ROM&quot;, &quot;Flash&quot;, &quot;EEPROM&quot;, &quot;FEPROM&quot;,
&quot;EPROM&quot;, &quot;CDRAM&quot;, &quot;3DRAM&quot;, &quot;SDRAM&quot;, &quot;SGRAM&quot;, &quot;RDRAM&quot;, &quot;DDR&quot;, &quot;DDR-2&quot;
$formfactor = &quot;Unknown&quot;, &quot;Other&quot;, &quot;SIP&quot;, &quot;DIP&quot;, &quot;ZIP&quot;, &quot;SOJ&quot;, &quot;Proprietary&quot;,
&quot;SIMM&quot;, &quot;DIMM&quot;, &quot;TSOP&quot;, &quot;PGA&quot;, &quot;RIMM&quot;, &quot;SODIMM&quot;, &quot;SRIMM&quot;, &quot;SMD&quot;, &quot;SSMP&quot;,
&quot;QFP&quot;, &quot;TQFP&quot;, &quot;SOIC&quot;, &quot;LCC&quot;, &quot;PLCC&quot;, &quot;BGA&quot;, &quot;FPBGA&quot;, &quot;LGA&quot;
$col1 = @{Name=&#39;Size (GB)&#39;; Expression={ $_.Capacity/1GB } }
$col2 = @{Name=&#39;Form Factor&#39;; Expression={$formfactor[$_.FormFactor]} }
$col3 = @{Name=&#39;Memory Type&#39;; Expression={ $memorytype[$_.MemoryType] } }

Get-WmiObject Win32_PhysicalMemory | Select-Object BankLabel, $col1, $col2, $col3

&lt;/pre&gt;&lt;br /&gt;
The output would be something like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ps&quot;&gt;BankLabel                     Size (GB) Form Factor         Memory Type
---------                     --------- -----------         -----------
                                      2 DIMM                DDR-2
                                      2 DIMM                DDR-2
                                      2 DIMM                DDR-2
                                      2 DIMM                DDR-2
&lt;/pre&gt;&lt;br /&gt;
It works pretty nice, doesn&#39;t it?</description><link>http://www.luisrocha.net/2010/06/checking-type-and-size-of-ram-with.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-2283009310847116446</guid><pubDate>Tue, 25 May 2010 00:54:00 +0000</pubDate><atom:updated>2010-05-24T18:54:05.936-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">.NET 4</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET MVC</category><category domain="http://www.blogger.com/atom/ns#">Chinook Database</category><title>MVC Music Store and Chinook Database</title><description>The &lt;a href=&quot;http://mvcmusicstore.codeplex.com/&quot;&gt;MVC Music Store&lt;/a&gt; is a sample application built on ASP.NET MVC Framework 2. It includes the source code and a tutorial explaining the steps to build it. This is a great tutorial if you want to get started on ASP.NET MVC 2. When I looked at the documentation, I noticed that the data used by the application is very familiar. Jon Galloway, the author, mentioned on this &lt;a href=&quot;http://weblogs.asp.net/jgalloway/archive/2010/05/12/introducing-the-mvc-music-store-mvc-2-sample-application-and-tutorial.aspx&quot;&gt;post&lt;/a&gt; that the MVC Music Store data is based on the &lt;a href=&quot;http://chinookdatabase.codeplex.com/&quot;&gt;Chinook Database&lt;/a&gt;. The Chinook Database was built using my iTunes library as sample data, and that is why I recognized some particular artists and albums: a mix of rock, heavy metal, classical music and Brazilian music. &lt;br /&gt;
As to the Chinook Database I have a list of improvements to be done and need to get sometime to work on a new release. I am also thinking about adding support to document-oriented databases such as &lt;a href=&quot;http://ravendb.net/&quot;&gt;Raven DB&lt;/a&gt; and &lt;a href=&quot;http://www.mongodb.org/&quot;&gt;MongoDB&lt;/a&gt;.</description><link>http://www.luisrocha.net/2010/05/mvc-music-store-and-chinook-database.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-5585538008038429766</guid><pubDate>Sat, 28 Nov 2009 22:31:00 +0000</pubDate><atom:updated>2010-06-11T23:24:00.643-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PowerShell</category><title>Setting Assembly Version with Windows PowerShell</title><description>I&#39;ve been using the &lt;a href=&quot;http://autobuildversion.codeplex.com/&quot;&gt;Build Version Increament&lt;/a&gt; add-in for Visual Studio to automatically set the assembly and file versions. It works fine, however, it only works when using the Visual Studio IDE and it requires you to setup every single project of your solution. If you need to increment the assembly version on an automated build (MS Build, &lt;a href=&quot;http://nant.sourceforge.net/&quot;&gt;NAnt&lt;/a&gt;, &lt;a href=&quot;http://github.com/JamesKovacs/psake&quot;&gt;PSake&lt;/a&gt;), then a PowerShell script would be a better solution.&lt;br /&gt;
&lt;br /&gt;
The following script, &lt;a href=&quot;http://cid-0db70edb4fcea49f.skydrive.live.com/self.aspx/Demos/PowerShell/SetVersion.ps1&quot;&gt;SetVersion.ps1&lt;/a&gt;, searches for AssemblyInfo.cs files in the current directory and its sub directories, and then updates the AssemblyVersion and AssemblyFileVersion. You can optionally provide the version number to use, or it will auto generate one for you. You can customize the &lt;span style=&quot;font-weight: bold;&quot;&gt;Generate-VersionNumber &lt;/span&gt;function to use your own version schema. Also, if you are using a source control that needs to check-out files before editing them, such as TFS and Perforce, then add the check-out command to the &lt;span style=&quot;font-weight: bold;&quot;&gt;Update-AssemblyInfoFiles &lt;/span&gt;function.&lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;brush: ps&quot;&gt;#-------------------------------------------------------------------------------
# Displays how to use this script.
#-------------------------------------------------------------------------------
function Help {
    &quot;Sets the AssemblyVersion and AssemblyFileVersion of AssemblyInfo.cs files`n&quot;
    &quot;.\SetVersion.ps1 [VersionNumber]`n&quot;
    &quot;   [VersionNumber]     The version number to set, for example: 1.1.9301.0&quot;
    &quot;                       If not provided, a version number will be generated.`n&quot;
}

#-------------------------------------------------------------------------------
# Generate a version number.
# Note: customize this function to generate it using your version schema.
#-------------------------------------------------------------------------------
function Generate-VersionNumber {
    $today = Get-Date
    return &quot;1.0.&quot; + ( ($today.year - 2000) * 1000 + $today.DayOfYear )+ &quot;.0&quot;
}
 
#-------------------------------------------------------------------------------
# Update version numbers of AssemblyInfo.cs
#-------------------------------------------------------------------------------
function Update-AssemblyInfoFiles ([string] $version) {
    $assemblyVersionPattern = &#39;AssemblyVersion\(&quot;[0-9]+(\.([0-9]+|\*)){1,3}&quot;\)&#39;
    $fileVersionPattern = &#39;AssemblyFileVersion\(&quot;[0-9]+(\.([0-9]+|\*)){1,3}&quot;\)&#39;
    $assemblyVersion = &#39;AssemblyVersion(&quot;&#39; + $version + &#39;&quot;)&#39;;
    $fileVersion = &#39;AssemblyFileVersion(&quot;&#39; + $version + &#39;&quot;)&#39;;
    
    Get-ChildItem -r -filter AssemblyInfo.cs | ForEach-Object {
        $filename = $_.Directory.ToString() + &#39;\&#39; + $_.Name
        $filename + &#39; -&gt; &#39; + $version
        
        # If you are using a source control that requires to check-out files before 
        # modifying them, make sure to check-out the file here.
        # For example, TFS will require the following command:
        # tf checkout $filename
    
        (Get-Content $filename) | ForEach-Object {
            % {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
            % {$_ -replace $fileVersionPattern, $fileVersion }
        } | Set-Content $filename
    }
}

#-------------------------------------------------------------------------------
# Parse arguments.
#-------------------------------------------------------------------------------
if ($args -ne $null) {
    $version = $args[0]
    if (($version -eq &#39;/?&#39;) -or ($version -notmatch &quot;[0-9]+(\.([0-9]+|\*)){1,3}&quot;)) {
        Help
        return;
    }
} else {
    $version =  Generate-VersionNumber
}

Update-AssemblyInfoFiles $version

&lt;/pre&gt;&lt;br /&gt;
And finally, before running this script, or any PowerShell script, make sure that you are allowed to execute scripts by running Get-ExecutionPolicy. If it returns Restricted, you need to run the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;brush: ps&quot;&gt;Set-ExecutionPolicy RemoteSigned
&lt;/pre&gt;&lt;br /&gt;
Download the entire script from &lt;a href=&quot;http://cid-0db70edb4fcea49f.skydrive.live.com/self.aspx/Demos/PowerShell/SetVersion.ps1&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Enjoy it!</description><link>http://www.luisrocha.net/2009/11/setting-assembly-version-with-windows.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-8295732307609989764</guid><pubDate>Wed, 18 Nov 2009 06:10:00 +0000</pubDate><atom:updated>2009-11-17T23:16:44.930-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Training</category><title>The Channel 9 Learning Center</title><description>If you want to learn the latest Microsoft technologies such as &lt;a href=&quot;http://channel9.msdn.com/learn/courses/VS2010/&quot;&gt;V2010 and .NET 4.0&lt;/a&gt;, &lt;a href=&quot;http://channel9.msdn.com/learn/courses/Azure/&quot;&gt;Windows Azure&lt;/a&gt;, and &lt;a href=&quot;http://channel9.msdn.com/learn/courses/SharePoint2010Developer/&quot;&gt;SharePoint 2010&lt;/a&gt;, then check it out the training course available at Channel 9 Learning Center:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://channel9.msdn.com/learn/&quot;&gt;http://channel9.msdn.com/learn/&lt;/a&gt;</description><link>http://www.luisrocha.net/2009/11/channel-9-learning-center.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-3827968713370130092</guid><pubDate>Mon, 12 Oct 2009 21:35:00 +0000</pubDate><atom:updated>2009-10-12T15:44:22.111-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SharePoint</category><title>Creating a SharePoint List Parent / Child Relationship – Out of the Box</title><description>I just came across this article about creating SharePoint lists with parent/child relationship using out-of-the-box functionality:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.endusersharepoint.com/2009/10/02/creating-a-sharepoint-list-parent-child-relationship-out-of-the-box/&quot;&gt;http://www.endusersharepoint.com/2009/10/02/creating-a-sharepoint-list-parent-child-relationship-out-of-the-box/&lt;/a&gt;</description><link>http://www.luisrocha.net/2009/10/creating-sharepoint-list-parent-child.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-8494990445254784416</guid><pubDate>Mon, 29 Jun 2009 00:15:00 +0000</pubDate><atom:updated>2010-06-12T10:30:08.186-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dynamics CRM</category><category domain="http://www.blogger.com/atom/ns#">Testing</category><title>Unit Testing CRM Plug-ins</title><description>&lt;span style=&quot;font-weight: bold;&quot;&gt;What is a CRM plug-in?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc151086.aspx&quot;&gt;plug-in&lt;/a&gt; is custom business logic that you can integrate with Microsoft Dynamics CRM 4.0 to modify or augment the standard behavior of the platform. This custom business logic can be executed based on a message pipeline execution model called &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc151078.aspx&quot;&gt;Event Execution Pipeline&lt;/a&gt;. A plug-in can be executed before or after a MS CRM platform event. For example, you can create a plug-in to validate the attributes of an account entity before the create and update operations.&lt;br /&gt;
&lt;br /&gt;
To create plug-ins, you need to create a normal .NET class library and reference the MS CRM SDK libraries. Then add a class that implements the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb959599.aspx&quot;&gt;Microsoft.Crm.Sdk.IPlugin&lt;/a&gt; interface.&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public interface IPlugin
{
    void Execute(IPluginExecutionContext context);
}
&lt;/pre&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Plug-in Unit Testing&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In order to write unit tests for your plug-in, you need to create at least a mock of the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb959587.aspx&quot;&gt;IPluginExecutionContext&lt;/a&gt;. Depending on your plug-in implementation, you will also need to mock &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc156387.aspx&quot;&gt;ICrmService&lt;/a&gt; or &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc156392.aspx&quot;&gt;IMetadataService&lt;/a&gt; if you are calling &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb959583.aspx&quot;&gt;IPluginExecutionContext.CreateCrmService&lt;/a&gt; or &lt;a href=&quot;http://technet.microsoft.com/en-us/library/bb959584.aspx&quot;&gt;IPluginExecutionContext.CreateMetadataService&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
There is the &lt;a href=&quot;http://code.msdn.microsoft.com/MSCRMPluginDebugger&quot;&gt;MS CRM Plug-in Debugger&lt;/a&gt;, which consists of a small EXE container that implements a mock of the IPluginExecutionContext interface. You could use this container to unit test your plug-ins. However, IMHO, I do not see any advantage in using it versus a unit test and a mock framework. I posted a comment on the &lt;a href=&quot;http://blogs.msdn.com/crm/archive/2008/05/12/testing-crm-plug-ins.aspx&quot;&gt;CRM Team Blog: Testing CRM Plug-in&lt;/a&gt; asking about that, but didn&#39;t get a response yet.&lt;br /&gt;
&lt;br /&gt;
To unit test a CRM plug in, you can use your favorite unit test framework (NUnit, MbUnit, Visual Studio Tests) and your favorite mock framework (Rhino Mocks, NMock, Typemocks). In this article, I will be using &lt;a href=&quot;http://www.nunit.org/index.php&quot;&gt;NUnit&lt;/a&gt; and &lt;a href=&quot;http://ayende.com/projects/rhino-mocks.aspx&quot;&gt;RhinoMocks&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;The Plug-in Code&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In the following example, adapted from the &quot;&lt;a href=&quot;http://www.microsoft.com/mspress/companion/9780735625945/&quot;&gt;Programming Microsoft Dynamics CRM 4.0&lt;/a&gt;&quot; book, the plug-in validates the account number attribute before saving the account entity.&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public class AccountNumberValidator : IPlugin
{
    public void Execute(IPluginExecutionContext context)
    {
        var target = (DynamicEntity) context.InputParameters[ParameterName.Target];

        if (target.Properties.Contains(&quot;accountnumber&quot;))
        {
            var accountNumber = target[&quot;accountnumber&quot;].ToString();
            var regex = new Regex(&quot;[A-Z]{2}-[0-9]{6}&quot;);

            if (!regex.IsMatch(accountNumber))
            {
                throw new InvalidPluginExecutionException(&quot;Invalid account number.&quot;);
            }
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
The code above checks to see if the account number attribute is in the right format. If not, it throws an &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb959578.aspx&quot;&gt;InvalidPluginExecutionException&lt;/a&gt;. Since we will register this plug-in as a pre-event of creating and updating the account entity, this exception will be handled by the CRM platform, and the create/update operation is aborted.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Writing the Plug-in Unit Test&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The following code is a simple test using NUnit to verify that an InvalidPluginExecutionException is thrown when the account entity has invalid account number:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;[Test]
[ExpectedException(typeof(InvalidPluginExecutionException))]
public void ShouldHandleInvalidAccountNumber([Values(&quot;&quot;,
                                                    &quot;AB123456&quot;,
                                                    &quot;A123456&quot;,
                                                    &quot;ABC123456&quot;,
                                                    &quot;AB-12345&quot;,
                                                    &quot;AB123456&quot;,
                                                    &quot;AB-123&quot;,
                                                    &quot;AB-1234&quot;,
                                                    &quot;aa-012345&quot;,
                                                    &quot;aa-000000&quot;,
                                                    &quot;Za-999999&quot;,
                                                    &quot;wW-936187&quot;)]
                                                    string number)
{
    // Create necessary mocks for the plug-in.
    var mocks = new MockRepository();
    var context = mocks.DynamicMock&amp;lt;IPluginExecutionContext&amp;gt;();

    // Creates a property bag for the plugin execution context mock.
    var target = new DynamicEntity();
    target.Properties[&quot;accountnumber&quot;] = number;
    var inputParameters = new PropertyBag();
    inputParameters.Properties[ParameterName.Target] = target;

    // Set expectations of mocks.
    Expect.Call(context.InputParameters).Return(inputParameters).Repeat.Any();
    mocks.ReplayAll();

    // Test the plug-in using the context mock.
    IPlugin plugin = new AccountNumberValidator();
    plugin.Execute(context);

    // Verify all the mocks.
    mocks.VerifyAll();
}
&lt;/pre&gt;&lt;br /&gt;
Now, we will go through all the details of this unit test:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The ExpectedException attribute defines the type of exception that this test expects to be raised. In our case, it is an InvalidPluginExecutionException.&lt;/li&gt;
&lt;li&gt;This is a parameterized test that uses the &lt;a href=&quot;http://www.nunit.org/index.php?p=values&amp;amp;r=2.5&quot;&gt;Values attribute&lt;/a&gt; to define a set of invalid account numbers. This test will run once for each value that we define. The Values attribute is specific to NUnit, but other frameworks have similar mechanisms: MbUnit uses RowTest for example.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;We create a mock of the IPluginExecutionContext interface by using the MockRepository.DynamicMock&lt;t&gt; method. We are using a DynamicMock because we are only interested in a small piece of the functionality (InputParameters property of the context object). If we want a complete control of the mock object behavior, then we would use a StrickMock. For more information about the types of mocks that you can create with Rhino Mocks, see &lt;a href=&quot;http://ayende.com/Wiki/Rhino+Mocks+Introduction.ashx&quot;&gt;here&lt;/a&gt;.&lt;/t&gt;&lt;/li&gt;
&lt;li&gt;The InputParameters property of the plug-in context, is a property bag that will contain the account number attribute. So, we create this property bag, and add the account number defined by the Values attribute parameter.&lt;/li&gt;
&lt;li&gt;Now, we set the expectations of the mock object. This step is called the Record state. When the InputParameters property is called, we expect it to return the property bag we created on the previous step. Note that we are using Repeat.Any() that means this property can be called more than once. In our test, we just want to make sure that InputParameters is called, no matter how many times.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;The Record state is finish by calling &lt;span style=&quot;font-weight: bold;&quot;&gt;ReplayAll()&lt;/span&gt;. This will move to the Replay state.&lt;/li&gt;
&lt;li&gt;Now, we are ready to instantiate our plug-in object and call its &lt;span style=&quot;font-weight: bold;&quot;&gt;Execute&lt;/span&gt; method using the plug-in context mock object.&lt;/li&gt;
&lt;li&gt;Finally, we call &lt;span style=&quot;font-weight: bold;&quot;&gt;VerifyAll()&lt;/span&gt; method, to verify that the mock expectations were satisfied. In our case, it will make sure that InputParameters property was called during the Replay state.&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;This test will assert that the plug-in Execute method will throw an InvalidPluginExecutionException with the account number values supplied.&lt;br /&gt;
&lt;br /&gt;
We also should write a test to assert that no InvalidPluginExecutionException is thrown when using valid account numbers. I will not include this test here, but you can see it on the solution source code files.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Mocking the ICrmService Interface&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In our previous test, we only need to mock the plug-in context interface. However, in more complex plug-ins, you might need to mock other interfaces such as the ICrmService. The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb959583.aspx&quot;&gt;CreateCrmService&lt;/a&gt; method of the IPluginExecutionContext creates an ICrmService object. If you use the CreateCrmService method on your plug-in, you will need to create a mock of ICrmService.&lt;br /&gt;
&lt;br /&gt;
Our validate account number plug-in has been changed to also detect duplicate account numbers. If an account number already exists, then the validation will fail by throwing an InvalidPluginExecutionException. To verify that the account number exists, we query CRM using the ICrmService.Fetch method with a FetchXML query. The following code demonstrate these changes:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;public class AccountNumberValidator : IPlugin
{
    /// &amp;lt;summary&amp;gt;
    /// 
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name=&quot;context&quot;&amp;gt;&amp;lt;/param&amp;gt;
    public void Execute(IPluginExecutionContext context)
    {
        var target = (DynamicEntity) context.InputParameters[ParameterName.Target];

        if (target.Properties.Contains(&quot;accountnumber&quot;))
        {
            var accountNumber = target[&quot;accountnumber&quot;].ToString();

            // Validates the account number format.
            var regex = new Regex(&quot;[A-Z]{2}-[0-9]{6}&quot;);
            if (!regex.IsMatch(accountNumber))
            {
                throw new InvalidPluginExecutionException(&quot;Invalid account number.&quot;);
            }

            // Validates the account number is unique.
            using (var service = context.CreateCrmService(true))
            {
                var query = string.Format(@&quot;&amp;lt;fetch mapping=&#39;logical&#39;&amp;gt;
                                                &amp;lt;entity name=&#39;account&#39;&amp;gt;
                                                &amp;lt;attribute name=&#39;accountnumber&#39; /&amp;gt;
                                                &amp;lt;filter&amp;gt;
                                                &amp;lt;condition attribute=&#39;accountnumber&#39;
                                                    operator=&#39;eq&#39; value=&#39;{0}&#39; /&amp;gt;
                                                &amp;lt;/filter&amp;gt;
                                                &amp;lt;/entity&amp;gt;
                                            &amp;lt;/fetch&amp;gt;&quot;,
                                            accountNumber);

            var results = service.Fetch(query);
            var xdocument = XDocument.Parse(results);
            var existingNumbers = from item in xdocument.Descendants(&quot;accountnumber&quot;)
            select item.Value;

            if (existingNumbers.Count() &amp;gt; 0)
                throw new InvalidPluginExecutionException(&quot;Account number already exist.&quot;);
            }
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;
Now, we will create a unit test to verify that our plug-in detects duplicate account numbers.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c-sharp&quot; name=&quot;code&quot;&gt;[Test]
[ExpectedException(typeof(InvalidPluginExecutionException))]
public void ShoulRejectDuplicateAccountNumber()
{
    // Create necessary mocks for the plug-in.
    var mocks = new MockRepository();
    var context = mocks.DynamicMock&amp;lt;IPluginExecutionContext&amp;gt;();
    var service = mocks.DynamicMock&amp;lt;ICrmService&amp;gt;();

    // Creates a property bag for the plugin execution context mock.
    var target = new DynamicEntity();
    target.Properties[&quot;accountnumber&quot;] = &quot;AB-123456&quot;;
    var inputParameters = new PropertyBag();
    inputParameters.Properties[ParameterName.Target] = target;

    // Set expectations of mocks.
    Expect.Call(context.InputParameters).Return(inputParameters).Repeat.Any();
    Expect.Call(context.CreateCrmService(true)).Return(service);
    Expect.Call(service.Fetch(null)).IgnoreArguments()
                .Return(@&quot;&amp;lt;resultset&amp;gt;
                            &amp;lt;result&amp;gt;
                                &amp;lt;accountnumber&amp;gt;AB-123456&amp;lt;/accountnumber&amp;gt;
                            &amp;lt;/result&amp;gt;
                        &amp;lt;/resultset&amp;gt;&quot;);
    mocks.ReplayAll();

    // Test the plug-in using the context mock.
    IPlugin plugin = new AccountNumberValidator();
    plugin.Execute(context);

    // Verify all the mocks.
    mocks.VerifyAll();
}
&lt;/pre&gt;&lt;br /&gt;
In the test above, we are using Rhino Mocks to create a mock for the ICrmService. This object will be returned by the CreateCrmService method of the plug-in execution context. We are also recording that when ICrmService.Fetch method is called, it will return a XML file containing a duplicated account number. This will simulate the CRM behavior of detecting that an account number already exists, and we can assert that our plug-in will fail the validation by throwing an exception.&lt;br /&gt;
&lt;br /&gt;
I hope this post helps you to unit test your CRM plug-ins. Although I demonstrated it using NUnit and Rhino Mocks, you can use any unit testing framework (NUnit, MbUnit, Visual Studio Tests, etc.) and any mock framework (Rhino Mocks, NMock, Typemocks, etc.).&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://cid-0db70edb4fcea49f.office.live.com/self.aspx/Demos/Crm4Plugin.zip&quot;&gt;Crm4Plugin.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><link>http://www.luisrocha.net/2009/06/unit-testing-crm-plug-ins.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-5135040009893139227</guid><pubDate>Tue, 16 Jun 2009 00:17:00 +0000</pubDate><atom:updated>2010-06-11T23:19:44.043-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dynamics CRM</category><title>Using Embedded Files for FetchXML Queries</title><description>&lt;a href=&quot;http://technet.microsoft.com/en-us/library/bb928434.aspx&quot;&gt;FetchXML&lt;/a&gt; is a proprietary language that it is used in Microsoft Dynamics CRM. All examples that I&#39;ve seen so far, always show the FetchXML query hard coded into the C# file. Instead of keeping the queries mixed with the source code, a bad practice IMHO, I prefer placing queries in separate XML files. These files can be embedded resources of the assembly. By placing them on a separate file, it isolates them from the code, making easier to locate, share and test them.  In order to embed your query in the assembly, you will need to add an XML file with the query into your project. Make sure to change its build action to &lt;span style=&quot;font-weight: bold;&quot;&gt;Embedded Resource&lt;/span&gt;. Then, use the following code to read the embedded XML file.  The code below assumes that the file was placed in the subfolder &lt;span style=&quot;font-weight: bold;&quot;&gt;Queries&lt;/span&gt; of the project. It refers to the embedded file by using the assembly name and the related path to the file. Notice that it uses &quot;.&quot; instead of &quot;\&quot; to refer to the embedded file. &lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;brush: csharp&quot;&gt;// Read the embedded fetch xml query file.
var assembly = Assembly.GetExecutingAssembly();
var stream = assembly.GetManifestResourceStream(&quot;MyAssembly.Queries.MyQuery.xml&quot;);

if (stream == null)
{
    throw new FileLoadException(&quot;Cannot load fetchXML embedded file&quot;);
}

// Gets the Fetch XML query string.
var reader = new StreamReader(stream);
string query = reader.ReadToEnd();

// Removing leading spaces to reduce the size of the xml request.
query = Regex.Replace(fetchXml, @&quot;\s+&quot;, @&quot; &quot;);

// Fetches the results.
string results = crmService.Fetch(query);
&lt;/pre&gt;&lt;br /&gt;
The code above uses a static query. If you need to use a dynamic query, then the XML can  contain the string format of the query, and you can use String.Format to pass the parameters needed to build your dynamic query.</description><link>http://www.luisrocha.net/2009/06/using-embedded-files-for-fetchxml.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9567658.post-956339050592044044</guid><pubDate>Thu, 21 May 2009 03:14:00 +0000</pubDate><atom:updated>2009-05-20T21:46:41.001-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">.NET 4</category><category domain="http://www.blogger.com/atom/ns#">Visual Studio 2010</category><title>Visual Studio 2010 and .NET 4 Beta 1</title><description>Visual Studio 2010 and .NET 4 Beta 1 is available today for the general public. Note that the new .NET version is 4 and not 4.0. You can download the beta from &lt;a href=&quot;http://blogs.msdn.com/onoj/archive/2009/05/19/visual-studio-2010-beta-1-download-options.aspx&quot;&gt;here&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also, check out &lt;a href=&quot;http://blogs.msdn.com/jasonz/archive/2009/05/18/announcing-vs2010-net-framework-4-0-beta-1.aspx&quot;&gt;Jason Zander&#39;s post&lt;/a&gt; where he highlights the new functionalities, and Brad Adams post with &lt;a href=&quot;http://blogs.msdn.com/brada/archive/2008/10/29/net-framework-4-poster.aspx&quot;&gt;.NET 4 poster&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am currently preparing a virtual machine with &lt;a href=&quot;http://www.microsoft.com/Windows/Windows-7/download.aspx&quot;&gt;Windows 7 RC 1&lt;/a&gt; and VS 2010 for trying out the new features.&lt;/div&gt;</description><link>http://www.luisrocha.net/2009/05/visual-studio-2010-and-net-4-beta-1.html</link><author>noreply@blogger.com (Luis Rocha)</author><thr:total>0</thr:total></item></channel></rss>