<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Hibernating Rhinos</title><link>http://blog.hibernatingrhinos.com/</link><description>Hibernating Rhinos</description><copyright>Hibernating Rhinos (c) 2009 - 2011 (c) 2013</copyright><ttl>60</ttl><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/HibernatingRhinos" /><feedburner:info uri="hibernatingrhinos" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>New Client Coming to RavenDB &amp;ndash; Mono For Android</title><description>&lt;p&gt;You requested it and we listened, we now have a client for Android (with mono).  &lt;p&gt;The client supports all the regular client side operation except from Distributed Transactions which are not relevant for mobile devices &lt;p&gt;The Client will be available through a Nuget Package or by referencing the dll to your project  &lt;p&gt;All you need to do is reference the Raven.Client.MonoForAndoird.dll to your Mono for android project. &lt;p&gt;In there you can use the code as you normally would.  &lt;p&gt;If you want to start working with this already you can download the dll here: &lt;p&gt;&lt;a href="https://www.dropbox.com/s/e2n5fioobv3v09u/Raven.Client.MonoForAndroid.dll"&gt;https://www.dropbox.com/s/e2n5fioobv3v09u/Raven.Client.MonoForAndroid.dll&lt;/a&gt; &lt;p&gt;Pay attention this is an early build, so if you have something not working, we will appreciate if you could create a failing test for it  &lt;p&gt;You can see how we are testing from this repository &lt;a href="https://github.com/DanielDar/ravendb"&gt;https://github.com/DanielDar/ravendb&lt;/a&gt; on branch 2.5  &lt;p&gt;Look at the project Raven.Tests.MonoForAndroid  &lt;p&gt;There is also Raven.Tryouts.MonoForAndroid for testing a complete app &lt;p&gt;You can see a sample for the using android with raven here: &lt;a href="https://github.com/DanielDar/RavenAndroidToDoList"&gt;https://github.com/DanielDar/RavenAndroidToDoList&lt;/a&gt; &lt;p&gt;In this sample you have a to do list that is updated between all of the android devices running it.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/4-W--JoU-ho" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/4-W--JoU-ho/new-client-coming-to-ravendb-ndash-mono-for-android</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12929/new-client-coming-to-ravendb-ndash-mono-for-android?key=97bd203b-dc4b-4c2f-8cbb-ad1a82a9a9ad</guid><pubDate>Thu, 21 Mar 2013 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12929/new-client-coming-to-ravendb-ndash-mono-for-android?key=97bd203b-dc4b-4c2f-8cbb-ad1a82a9a9ad</feedburner:origLink></item><item><title>EFProf now supports EF 6 alpha 3</title><description>&lt;p&gt;We got a mail from a customer asking about the support of &lt;a href="http://nuget.org/packages/EntityFramework/6.0.0-alpha3"&gt;Entity Framework 6 alpha 3&lt;/a&gt; by the &lt;a href="http://hibernatingrhinos.com/products/efprof"&gt;Entity Framework Profiler&lt;/a&gt;. It took 2 hours before we got a new build which now support it. &lt;/p&gt; &lt;p&gt;Part of this speedy patch was that the customer provided a nice small project that reproduce the issue, which is always the best way to get things fixed fast, but the most critical thing was that the EF team addressed the issues that we faced in the previous release, &lt;a href="http://nuget.org/packages/EntityFramework/6.0.0-alpha2"&gt;EF 6 alpha 2&lt;/a&gt;, as outlined &lt;a href="http://blog.hibernatingrhinos.com/12802/entity-framework-profiler-support-for-entity-framework-6-alpha-2"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;So if you are using EF 6 alpha 3, the workaround that was outlined &lt;a href="http://blog.hibernatingrhinos.com/12802/entity-framework-profiler-support-for-entity-framework-6-alpha-2"&gt;here&lt;/a&gt; is not needed anymore.&amp;nbsp; You should just call `EntityFrameworkProfiler.Initialize()` at the very first of your application and this is it.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/Y3eqG6AAQOM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/Y3eqG6AAQOM/efprof-now-supports-ef-6-alpha-3</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12897/efprof-now-supports-ef-6-alpha-3?key=ec97bbae-6d70-4319-83b1-196b27acca10</guid><pubDate>Wed, 13 Mar 2013 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12897/efprof-now-supports-ef-6-alpha-3?key=ec97bbae-6d70-4319-83b1-196b27acca10</feedburner:origLink></item><item><title>Use ProfilerIntegration static class in order to hook into the profiler</title><description>&lt;p&gt;A user asked us how can he use this class so I thought it may be a good idea to blog about that.&lt;/p&gt; &lt;p&gt;You can use the HibernatingRhinos.Profiler.Appender.ProfilerIntegration static class in order to hook into the profiler and do some interesting staff.&lt;/p&gt; &lt;p&gt;The two most uses of this class is 1. telling the profiler to ignore some code and not record it. 2. record something that wasn’t executed by the ORM but by ADO.NET directly in the profiler. &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Ignore and not profile a portion of code&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This is mostly useful when running unit tests and you need to do some initialization to the database which you prefer not to see in the profiler output. &lt;/p&gt; &lt;p&gt;You can do this using:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (ProfilerIntegration.IgnoreAll())
{
    // Do something
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Or&lt;/p&gt;&lt;pre class="csharpcode"&gt;ProfilerIntegration.IgnoreAll();
&lt;span class="rem"&gt;// Do something&lt;/span&gt;
ProfilerIntegration.ResumeProfiling();&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Record custom messages inside the profiler&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is mostly useful if you doing some use of the pure ADO.NET api alongside to the ORM that you’re using and you want to record those actions.&lt;/p&gt;
&lt;p&gt;In this case, since you aren’t using the DbConnection/DbDataReader/DbCommnad etc that the profiler created, you’ll need to notify the profiler about each action.&lt;/p&gt;
&lt;p&gt;This can be done using the following code:&lt;/p&gt;&lt;pre class="csharpcode"&gt;ProfilerIntegration.PublishProfilerEvent(&lt;span class="str"&gt;"session id"&lt;/span&gt;, &lt;span class="str"&gt;"logger name"&lt;/span&gt;, &lt;span class="str"&gt;"message"&lt;/span&gt;);&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;This is 3 parameters:&lt;/p&gt;
&lt;p&gt;Session ID = a string that identify the session to which this statement belongs. In NHibernate you’ll want to use ((SessionImpl)session).SessionId.ToString(). In the other ORM, you can use some GUID which should be the same for statements in this session.&lt;/p&gt;
&lt;p&gt;Logger name = specifies the log type. This is ORM specific, in NHibernate you’ll use "NHibernate.SQL" in order to log a statement while that in EF this will be "EntityFramework.Sql".&lt;/p&gt;
&lt;p&gt;Message = The actual message to record. If this an SQL statement, you’ll provide the SQL statement here.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;&lt;pre class="csharpcode"&gt;            &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; sql =
                &lt;span class="str"&gt;@"SELECT
        first 5 this_.LOG_ID as LOG1_0_0_,
        this_.LOG_DATE as LOG2_0_0_,
        this_.APP_NAME as APP3_0_0_,
        this_.LOGGER as LOGGER0_0_,
        this_.LOG_LEVEL as LOG5_0_0_,
        this_.MESSAGE as MESSAGE0_0_,
        this_.EXCEPTION_MESSAGE as EXCEPTION7_0_0_,
        this_.CONTEXT as CONTEXT0_0_
FROM APP_LOG this_ ORDER BY this_.LOG_DATE desc"&lt;/span&gt;;

            &lt;span class="kwrd"&gt;using&lt;/span&gt; (var s = (SessionImpl)factory.OpenSession())
            {
                ProfilerIntegration.PublishProfilerEvent(
                    s.SessionId.ToString(),
                    &lt;span class="str"&gt;"NHibernate.SQL"&lt;/span&gt;,
                    sql);
            }&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;PublishProfilerEvent is really low level API. If you’re using Entity Framework Profiler you can use the EntityFrameworkAppender class which provides more high level API:&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;var sessionId = Guid.NewGuid();&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;var entityFrameworkAppender = &lt;span class="kwrd"&gt;new&lt;/span&gt; EntityFrameworkAppender(&lt;span class="str"&gt;"My app"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;entityFrameworkAppender.ConnectionStarted(sessionId);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;var statementId = Guid.NewGuid();&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;entityFrameworkAppender.StatementExecuted(sessionId, statementId, &lt;span class="str"&gt;"Select ..."&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;entityFrameworkAppender.StatementRowCount(sessionId, statementId, 8);&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;entityFrameworkAppender.StatementError(sessionId, &lt;span class="kwrd"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span class="str"&gt;"Report an error to the profiler"&lt;/span&gt;));&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;entityFrameworkAppender.ConnectionDisposed(sessionId);&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;But this is considered internal API which may be changed.&lt;/p&gt;
&lt;p&gt;NHibernateProfiler doesn’t expose a high level API like this, so you’ll need to call ProfilerIntegration.PublishProfilerEvent with the correct logger name. If you would like to know a particular logger name you can email us and we’ll provide you with the information that you need.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/E8205Ukzf4o" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/E8205Ukzf4o/use-profilerintegration-static-class-in-order-to-hook-into-the-profiler</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12865/use-profilerintegration-static-class-in-order-to-hook-into-the-profiler?key=7396d7cc-64c6-4e1a-9d6a-b985f79c5b87</guid><pubDate>Wed, 30 Jan 2013 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12865/use-profilerintegration-static-class-in-order-to-hook-into-the-profiler?key=7396d7cc-64c6-4e1a-9d6a-b985f79c5b87</feedburner:origLink></item><item><title>Use log4net version 1.2.11.0 with NHibernate Profiler</title><description>&lt;p&gt;We got lots of requests to support log4net 1.2.11.0 when using the web.config or app.config to configure the profiler. We already supported log4net 1.2.11 if you initialized the profiler using code, eg NHibernateProfiler.Initialize(), by auto compiling our inner appedner against the version of log4net that your application is using. But when you initialize the profiler using config file you need an assembly that is already compiled against log4net.&lt;/p&gt; &lt;p&gt;We thought how we can support this, and we came up with an interesting solution. &lt;/p&gt; &lt;p&gt;Starting with build &lt;a href="http://hibernatingrhinos.com/builds/uber-prof-v2/2122"&gt;#2122&lt;/a&gt;, we let you call the following code from your application, which will generate an assembly that will be compiled against the version of log4net that your application is using, and will be saved to the location that you can specify in the parameter:&lt;/p&gt;&lt;pre class="csharpcode"&gt;NHibernateProfiler.GenerateAssemblyForCustomVersionOfLog4Net(AppDomain.CurrentDomain.BaseDirectory);&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;This will create the following dll in the output folder: &lt;/p&gt;
&lt;p&gt;HibernatingRhinos.Profiler.Appender.CustomNHibernateLog4Net.dll&lt;/p&gt;
&lt;p&gt;Now you can use this dll in order to initialize the profiler using the configuration file.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/vPaGS_6Vf4s" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/vPaGS_6Vf4s/use-log4net-version-1-2-11-0-with-nhibernate-profiler</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12833/use-log4net-version-1-2-11-0-with-nhibernate-profiler?key=b29bd684-11cb-46cd-a44d-8788035b437a</guid><pubDate>Thu, 24 Jan 2013 12:51:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12833/use-log4net-version-1-2-11-0-with-nhibernate-profiler?key=b29bd684-11cb-46cd-a44d-8788035b437a</feedburner:origLink></item><item><title>Entity Framework Profiler support for Entity Framework 6 alpha 2</title><description>&lt;p&gt;Recently a lot of our users asked us to support &lt;a href="http://nuget.org/packages/EntityFramework/6.0.0-alpha2"&gt;Entity Framework 6 alpha 2&lt;/a&gt; in &lt;a href="http://www.hibernatingrhinos.com/products/efprof"&gt;Entity Framework Profiler&lt;/a&gt;. We started to look on how we can support it right away but we found that we could not support it easily.&lt;/p&gt; &lt;p&gt;The main issue was that &lt;a href="http://nuget.org/packages/EntityFramework/6.0.0-alpha2"&gt;Entity Framework 6 alpha 2&lt;/a&gt; expose a class called &lt;a href="http://entityframework.codeplex.com/wikipage?title=Code-based%20Configuration"&gt;DbConfiguration&lt;/a&gt; which you can use as an injection point to EF. But the way that EF currently works, it looks for this class only in the same assembly that uses the DbContext, which is your application executable/dll but not our appender dll.&lt;/p&gt; &lt;p&gt;So we contact the EF team (which they were very helpful and responsive) and discussed some of the issues that we saw. While a few of the issues was been addressed already by the EF team and committed to the EF repository, the good news that we found a way to support &lt;a href="http://nuget.org/packages/EntityFramework/6.0.0-alpha2"&gt;Entity Framework 6 alpha 2&lt;/a&gt; by adding just one source file to your application.&lt;/p&gt; &lt;p&gt;Take the following file and add to your application: &lt;a title="https://gist.github.com/4539561" href="https://gist.github.com/4539561"&gt;https://gist.github.com/4539561&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;Now make sure to use the use build &lt;a href="http://hibernatingrhinos.com/builds/uber-prof-v2/2111"&gt;#2111&lt;/a&gt; or later of &lt;a href="http://www.hibernatingrhinos.com/products/efprof"&gt;Entity Framework Profiler&lt;/a&gt; and it will work.&lt;/p&gt; &lt;p&gt;I’m also attaching the same source code from the &lt;a href="https://gist.github.com/4539561"&gt;above gist&lt;/a&gt; to here. Enjoy using Entity Framework Profiler! &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Common;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Entity.Config;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Entity.Core.Common;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Entity.Core.EntityClient;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Entity.Infrastructure;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Entity.Migrations.Sql;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data.Entity.SqlServer;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Reflection;
&lt;span class="kwrd"&gt;using&lt;/span&gt; HibernatingRhinos.Profiler.Appender.EntityFramework;
&lt;span class="kwrd"&gt;using&lt;/span&gt; HibernatingRhinos.Profiler.Appender.ProfiledDataAccess;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; HibernatingRhinos.Profiler.IntegrationTests.EntityFramework6Beta2
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ProfiledDbConfiguration : DbConfiguration
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; ProfiledDbConfiguration()
        {
            AddDependencyResolver(&lt;span class="kwrd"&gt;new&lt;/span&gt; ProfiledDbDependencyResolver(&lt;span class="kwrd"&gt;this&lt;/span&gt;));
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ProfiledDbDependencyResolver : IDbDependencyResolver
    {
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; IDbDependencyResolver rootResolver;

&lt;span class="preproc"&gt;#if&lt;/span&gt; DEBUG
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; HashSet&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; types = &lt;span class="kwrd"&gt;new&lt;/span&gt; HashSet&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;();
&lt;span class="preproc"&gt;#endif&lt;/span&gt;

        &lt;span class="kwrd"&gt;public&lt;/span&gt; ProfiledDbDependencyResolver(DbConfiguration originalDbConfiguration)
        {
            &lt;span class="rem"&gt;// Get the original resolver&lt;/span&gt;
            var internalConfigProp = originalDbConfiguration.GetType().GetProperty(&lt;span class="str"&gt;"InternalConfiguration"&lt;/span&gt;, BindingFlags.Instance | BindingFlags.NonPublic);
            var internalConfig = internalConfigProp.GetValue(originalDbConfiguration, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
            var rootResolverProp = internalConfig.GetType().GetProperty(&lt;span class="str"&gt;"RootResolver"&lt;/span&gt;, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            rootResolver = (IDbDependencyResolver)rootResolverProp.GetValue(internalConfig, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; GetService(Type type, &lt;span class="kwrd"&gt;object&lt;/span&gt; key)
        {
&lt;span class="preproc"&gt;#if&lt;/span&gt; DEBUG
            types.Add(type.Name);
&lt;span class="preproc"&gt;#endif&lt;/span&gt;

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (type == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(IDbProviderFactoryService))
            {
                var innerFactoryService = (IDbProviderFactoryService) rootResolver.GetService(type, key);
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ProfiledDbProviderFactoryService(innerFactoryService);
            }

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (type == &lt;span class="kwrd"&gt;typeof&lt;/span&gt; (DbProviderServices))
            {
                var inner = (DbProviderServices)rootResolver.GetService(type, key);
                var appender = &lt;span class="kwrd"&gt;new&lt;/span&gt; EntityFrameworkAppender(&lt;span class="kwrd"&gt;typeof&lt;/span&gt; (SqlProviderServices).Name);
                var profiledDbProviderServicesType = EntityFrameworkProfiler.CompiledAssembly.GetType(&lt;span class="str"&gt;"HibernatingRhinos.Profiler.Appender.EntityFramework.ProfiledDbProviderServices"&lt;/span&gt;);
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (profiledDbProviderServicesType == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
                    &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span class="str"&gt;"Could not get the profiled DbProviderServices."&lt;/span&gt;);
                &lt;span class="kwrd"&gt;return&lt;/span&gt; Activator.CreateInstance(profiledDbProviderServicesType, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] {inner, appender});
            }

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (type == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(MigrationSqlGenerator))
            {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (rootResolver.GetService(type, key) &lt;span class="kwrd"&gt;is&lt;/span&gt; SqlServerMigrationSqlGenerator)
                {
                    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ProfiledMigrationSqlGenerator();
                }
            }

            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ProfiledDbProviderFactoryService : IDbProviderFactoryService
    {
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; IDbProviderFactoryService innerFactoryService;

        &lt;span class="kwrd"&gt;public&lt;/span&gt; ProfiledDbProviderFactoryService(IDbProviderFactoryService innerFactoryService)
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.innerFactoryService = innerFactoryService;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; DbProviderFactory GetProviderFactory(DbConnection connection)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (connection &lt;span class="kwrd"&gt;is&lt;/span&gt; ProfiledConnection)
            {
                var connectionType = connection.GetType();
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (connectionType.IsGenericType)
                {
                    var innerProviderFactory = connectionType.GetGenericArguments()[0];
                    var profiledDbProviderFactory = EntityFrameworkProfiler.CompiledAssembly.GetType(&lt;span class="str"&gt;"HibernatingRhinos.Profiler.Appender.EntityFramework.ProfiledDbProviderFactory`1"&lt;/span&gt;).MakeGenericType(innerProviderFactory);
                    &lt;span class="kwrd"&gt;return&lt;/span&gt; (DbProviderFactory) Activator.CreateInstance(profiledDbProviderFactory);
                }
            }

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (connection &lt;span class="kwrd"&gt;is&lt;/span&gt; EntityConnection)
                &lt;span class="kwrd"&gt;return&lt;/span&gt; innerFactoryService.GetProviderFactory(connection);

            &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span class="str"&gt;"Should have ProfiledConnection but got "&lt;/span&gt; + connection.GetType().FullName + &lt;span class="str"&gt;".If you got here, you probably need to modify the above code in order to satisfy the requirements of your application. This code indented to support EF 6 alpha 2."&lt;/span&gt;);
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ProfiledMigrationSqlGenerator : SqlServerMigrationSqlGenerator
    {
        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; DbConnection CreateConnection()
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; DbProviderFactories.GetFactory(&lt;span class="str"&gt;"System.Data.SqlClient"&lt;/span&gt;).CreateConnection();
        }
    }
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/c4aFZI-58_g" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/c4aFZI-58_g/entity-framework-profiler-support-for-entity-framework-6-alpha-2</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12802/entity-framework-profiler-support-for-entity-framework-6-alpha-2?key=48ee1331-892e-4b55-a720-8853d876c193</guid><pubDate>Thu, 17 Jan 2013 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12802/entity-framework-profiler-support-for-entity-framework-6-alpha-2?key=48ee1331-892e-4b55-a720-8853d876c193</feedburner:origLink></item><item><title>Hibernate Profiler now supports Hibernate 4</title><description>&lt;p&gt;Starting from build &lt;a href="http://hibernatingrhinos.com/builds/uber-prof-v2/2112"&gt;#2112&lt;/a&gt;, &lt;a href="http://www.hibernatingrhinos.com/products/hprof"&gt;Hibernate Profiler&lt;/a&gt; now fully supports Hibernate 4.&lt;/p&gt; &lt;p&gt;Instructions how to setup &lt;a href="http://www.hibernatingrhinos.com/products/hprof"&gt;Hibernate Profiler&lt;/a&gt; can be found here: &lt;a title="http://hibernatingrhinos.com/products/hprof/learn/general/gettingstarted" href="http://hibernatingrhinos.com/products/hprof/learn/general/gettingstarted"&gt;http://hibernatingrhinos.com/products/hprof/learn/general/gettingstarted&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;We think to provide a maven package for Hibernate Profiler for you, so instead of downloading Hibernate Profiler by hand you’ll be able to use maven in order to get the binaries. Would you like to see this feature coming? Tell us in the comments!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/V-qdIb-gM5g" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/V-qdIb-gM5g/hibernate-profiler-now-supports-hibernate-4</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12801/hibernate-profiler-now-supports-hibernate-4?key=3739c7e1-9aa8-4a82-b790-4c134dce6f86</guid><pubDate>Wed, 16 Jan 2013 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12801/hibernate-profiler-now-supports-hibernate-4?key=3739c7e1-9aa8-4a82-b790-4c134dce6f86</feedburner:origLink></item><item><title>Uber Prof Production Profiling&amp;ndash;Profiling production application on Azure</title><description>&lt;p&gt;In this post I’m going to cover one of the great features of Uber Prof v2.0: production profiling of remote applications running on Windows Azure.&lt;/p&gt; &lt;p&gt;The production profiling feature is currently supported in the following profilers: &lt;a href="http://nhprof.com/"&gt;NHibernate Profiler&lt;/a&gt;, &lt;a href="http://efprof.com/"&gt;Entity Framework Profiler&lt;/a&gt;, &lt;a href="http://l2sprof.com/"&gt;Linq to SQL Profiler&lt;/a&gt;, &lt;a href="http://llblgenprof.com/"&gt;LLBLGen Profiler&lt;/a&gt;. In this post I’m going to demonstrate how to use this with the &lt;a href="http://efprof.com/"&gt;Entity Framework Profiler&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;First, we need to create our project. Since we want to host the project on Windows Azure, I’ll use an ASP.NET MVC + Web API project.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling1.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ProductionProfiling1" border="0" alt="ProductionProfiling1" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling1_thumb.png" width="959" height="665"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The next thing is to enable production profiling. In order to so, we need to install the &lt;a href="http://nuget.org/packages/EntityFrameworkProfiler.Production"&gt;EntityFrameworkProfiler.Production&lt;/a&gt; NuGet package. &lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ProductionProfiling2" border="0" alt="ProductionProfiling2" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling2_thumb.png" width="1208" height="691"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As a side note, if you wonder what is the other package called &lt;a href="http://nuget.org/packages/EntityFrameworkProfiler"&gt;EntityFrameworkProfiler&lt;/a&gt;, you probably want to read this &lt;a href="http://blog.hibernatingrhinos.com/4/nuget-packages-and-an-example-use-of-the-profiler"&gt;post&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;After the package is installed, you can see that it created the following file in our project:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Web.Http;
&lt;span class="kwrd"&gt;using&lt;/span&gt; HibernatingRhinos.Profiler.Production;

[assembly: WebActivator.PreApplicationStartMethod(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ProductionProfilingOnAzureSample.App_Start.EntityFrameworkProfilerProductionBootstrapper), &lt;span class="str"&gt;"PreStart"&lt;/span&gt;)]
&lt;span class="kwrd"&gt;namespace&lt;/span&gt; ProductionProfilingOnAzureSample.App_Start
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EntityFrameworkProfilerProductionBootstrapper
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PreStart()
        {
            &lt;span class="rem"&gt;// Initialize the profiler with the production profiling feature. &lt;/span&gt;
            &lt;span class="rem"&gt;// Production profiling let's you let you see profiling information remotely using the following URL: http://your-server/profiler/profiler.html&lt;/span&gt;
            &lt;span class="kwrd"&gt;string&lt;/span&gt; license = GetResource(&lt;span class="str"&gt;"ProductionProfilingOnAzureSample.App_Start.EntityFrameworkProfilerLicense.xml"&lt;/span&gt;);
            ProductionProfiling.Initialize(license, GlobalConfiguration.Configuration);
        }

        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetResource(&lt;span class="kwrd"&gt;string&lt;/span&gt; sourcesResource)
        {
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (var sourceCodeStream = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(EntityFrameworkProfilerProductionBootstrapper).Assembly.GetManifestResourceStream(sourcesResource))
            {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (sourceCodeStream == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
                    &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"Resource file is missing: {0}"&lt;/span&gt;, sourcesResource));
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; StreamReader(sourceCodeStream).ReadToEnd();
            }
        }
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;This class will run on the startup of your project and will expose a URL endpoint that we can use to load the profiler UI. In this case we’re using the GlobalConfiguration.Configuration from the &lt;a href="http://nuget.org/packages/Microsoft.AspNet.WebApi.WebHost"&gt;WebAPI Web Host&lt;/a&gt; package, but please note that you can also expose your own self hosted server in order to production profile a different types of projects, like a service, or what not…&lt;/p&gt;
&lt;p&gt;Also note that we’re embedding the license file as an embedded resource in our project and we’re passing the license string to the Initialize method of the ProductionProfiling class. This is needed since the profiler is now split into to parts, the server – which is embedded right into your application and will run within your application own process, and the UI client which is a Silverlight application that you can get from the remote server through your browser. So again, the license string is passed and evaluated right from the server initialization process.&lt;/p&gt;
&lt;p&gt;Now it’s time to run our project. I’m running it but get the following exception: …&lt;/p&gt;
&lt;h4&gt;&lt;i&gt;Resource file is missing: ProductionProfilingOnAzureSample.App_Start.EntityFrameworkProfilerLicense.xml&lt;/i&gt;&lt;/h4&gt;&lt;b&gt;Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;br&gt;&lt;b&gt;Exception Details: &lt;/b&gt;System.InvalidOperationException: Resource file is missing: ProductionProfilingOnAzureSample.App_Start.EntityFrameworkProfilerLicense.xml&lt;br&gt;&lt;b&gt;Source Error:&lt;/b&gt; 
&lt;p&gt;&lt;code&gt;&lt;pre&gt;Line 22: 			{
Line 23: 				if (sourceCodeStream == null)
Line 24: 					throw new InvalidOperationException(string.Format("Resource file is missing: {0}", sourcesResource));
Line 25: 				return new StreamReader(sourceCodeStream).ReadToEnd();
Line 26: 			}&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;&lt;b&gt;Source File: &lt;/b&gt;c:\Users\Fitzchak\Documents\Visual Studio 11\Projects\ProductionProfilingOnAzureSample\ProductionProfilingOnAzureSample\App_Start\EntityFrameworkProfilerBootstrapper.cs&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Line: &lt;/b&gt;24 
&lt;p&gt;Remember what I told you? We need to embedded a license file. So let’s go and ask for a trial license file: &lt;a title="http://hibernatingrhinos.com/products/efprof/trial" href="http://hibernatingrhinos.com/products/efprof/trial"&gt;http://hibernatingrhinos.com/products/efprof/trial&lt;/a&gt;. 
&lt;p&gt;After that I’m doing that, I got a trial license in my email inbox. Now we need to include this in the project as an embedded resource. 
&lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ProductionProfiling3" border="0" alt="ProductionProfiling3" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling3_thumb.png" width="1300" height="691"&gt;&lt;/a&gt; 
&lt;p&gt;And now we are ready to see the profiler in action. Run the project and browse to the /profiler/profiler.html endpoint: 
&lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ProductionProfiling4" border="0" alt="ProductionProfiling4" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling4_thumb.png" width="875" height="692"&gt;&lt;/a&gt; 
&lt;p&gt;Do you see that? This is Entity Framework Profiler running right in your browser and let you profile your remote production application right from your computer! 
&lt;p&gt;You may be wonder why we do not see actual data in the profiler yet but this is your work to do. Attach it to your application and you’ll see some nice information that will let you understand what your ORM is doing easily. 
&lt;p&gt;Here is an example: 
&lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ScreenShots-EFProf-InBrowser%20(1)_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ScreenShots-EFProf-InBrowser (1)" border="0" alt="ScreenShots-EFProf-InBrowser (1)" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ScreenShots-EFProf-InBrowser%20(1)_thumb.png" width="1034" height="655"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Wait a second… Didn’t you said that we’re going to run this on Azure?&lt;/p&gt;
&lt;p&gt;Yes, I added the following code to the HomeController and pushed the code to azure:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; HomeController : Controller
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index()
    {
        &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 2; i++)
        {
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (var context = &lt;span class="kwrd"&gt;new&lt;/span&gt; ApplicationContext())
            {

                context.Messages.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; Message {Text = &lt;span class="str"&gt;"Text 1"&lt;/span&gt;, CreatedAt = DateTime.UtcNow});
                context.SaveChanges();

                var messages = context.Messages.ToList();

                var messages2 = context.Messages
                                        .Where(message =&amp;gt; message.Text == &lt;span class="str"&gt;"Profiling on Azure"&lt;/span&gt; &amp;amp;&amp;amp; message.Text.Length &amp;gt; 10)
                                        .ToList();
            }
        }
        &lt;span class="kwrd"&gt;return&lt;/span&gt; View();
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;You can run the above code by opening the following page,&amp;nbsp; &lt;a title="http://efprof.cloudapp.net/" href="http://efprof.cloudapp.net/"&gt;http://efprof.cloudapp.net/&lt;/a&gt;, and see the profiler in action here: &lt;a title="http://efprof.cloudapp.net/profiler/profiler.html" href="http://efprof.cloudapp.net/profiler/profiler.html"&gt;http://efprof.cloudapp.net/profiler/profiler.html&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling6.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ProductionProfiling6" border="0" alt="ProductionProfiling6" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/4e4ffe7a257b_D82A/ProductionProfiling6_thumb.png" width="1215" height="777"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For any feedback, please contact us in the profilers forums, by email (&lt;a href="mailto:support@hibernatingrhinos.com"&gt;support at hibernatingrhinos.com&lt;/a&gt;) or just leave a comment here.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/C9MVVovLhLw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/C9MVVovLhLw/uber-prof-production-profilingndash-profiling-production-application-on-azure</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12769/uber-prof-production-profilingndash-profiling-production-application-on-azure?key=6fc682a1-2959-42c5-92ad-8f11b18ec185</guid><pubDate>Mon, 17 Dec 2012 16:18:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12769/uber-prof-production-profilingndash-profiling-production-application-on-azure?key=6fc682a1-2959-42c5-92ad-8f11b18ec185</feedburner:origLink></item><item><title>What&amp;rsquo;s new in Uber Prof v2.0?</title><description>&lt;p&gt;Along with the launch of our new website &lt;a href="http://hibernatingrhinos.com/"&gt;hibernatingrhinos.com&lt;/a&gt;, we’re happy to announce that v2.0 of &lt;a href="http://hibernatingrhinos.com/products/UberProf'"&gt;Uber Prof&lt;/a&gt; profilers is now in beta!&lt;/p&gt; &lt;p&gt;While we’re perfecting the product, you can take advantage on that and buy a license now with a 20% discount. This will work for both monthly license and standard license.&lt;/p&gt; &lt;p&gt;You can also request a trial license on the website, which will let you use the profiler for 30 days.&lt;/p&gt; &lt;div align="center"&gt; &lt;table border="0" cellspacing="0" cellpadding="10" width="497" align="center"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="226"&gt;&lt;a href="http://hibernatingrhinos.com/products/UberProf"&gt;Uber Profiler&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="82"&gt;&lt;a href="http://hibernatingrhinos.com/products/uberprof/buy"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="71"&gt;&amp;nbsp;&lt;/td&gt; &lt;td valign="top" width="116"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="225"&gt;&lt;a href="http://hibernatingrhinos.com/products/nhprof"&gt;NHibernate Profiler&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="82"&gt;&lt;a href="http://hibernatingrhinos.com/products/nhprof/buy"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="71"&gt;&lt;a href="http://hibernatingrhinos.com/products/nhprof/trial"&gt;Try&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="116"&gt;&lt;a href="http://hibernatingrhinos.com/products/nhprof/screen-shots"&gt;Screen Shots&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="225"&gt;&lt;a href="http://hibernatingrhinos.com/products/hprof"&gt;Hibernate Profiler&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="82"&gt;&lt;a href="http://hibernatingrhinos.com/products/hprof/buy"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="71"&gt;&lt;a href="http://hibernatingrhinos.com/products/hprof/trial"&gt;Try&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="116"&gt;&lt;a href="http://hibernatingrhinos.com/products/hprof/screen-shots"&gt;Screen Shots&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="225"&gt;&lt;a href="http://hibernatingrhinos.com/products/efprof"&gt;Entity Framework Profiler&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="82"&gt;&lt;a href="http://hibernatingrhinos.com/products/efprof/buy"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="71"&gt;&lt;a href="http://hibernatingrhinos.com/products/efprof/trial"&gt;Try&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="116"&gt;&lt;a href="http://hibernatingrhinos.com/products/efprof/screen-shots"&gt;Screen Shots&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="225"&gt;&lt;a href="http://hibernatingrhinos.com/products/l2sprof"&gt;Linq to SQL Profiler&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="82"&gt;&lt;a href="http://hibernatingrhinos.com/products/l2sprof/buy"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="71"&gt;&lt;a href="http://hibernatingrhinos.com/products/l2sprof/trial"&gt;Try&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="116"&gt;&lt;a href="http://hibernatingrhinos.com/products/l2sprof/screen-shots"&gt;Screen Shots&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="225"&gt;&lt;a href="http://hibernatingrhinos.com/products/llblgenprof"&gt;LLBLGen Profiler&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="82"&gt;&lt;a href="http://hibernatingrhinos.com/products/llblgenprof/buy"&gt;Buy&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="71"&gt;&lt;a href="http://hibernatingrhinos.com/products/llblgenprof/trial"&gt;Try&lt;/a&gt;&lt;/td&gt; &lt;td valign="top" width="116"&gt;&lt;a href="http://hibernatingrhinos.com/products/llblgenprof/screen-shots"&gt;Screen Shots&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;p&gt;Now for the interesting staff, what’s new in Uber Prof v2.0?&lt;/p&gt; &lt;p&gt;1. &lt;strong&gt;Silverlight interface.&lt;/strong&gt; When you run the profiler.exe the UI that opens is a OOB Silverlight application. You can also open the profiler interface in your browser, which means that you can profiler remote systems! In fact, we ported all of the WPF user interface of v1.0 to Silverlight in order to enable production profiling of remote systems. &lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/7518d0a66173_9607/ScreenShots-NHProf-StatementDetails_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ScreenShots-NHProf-StatementDetails" border="0" alt="ScreenShots-NHProf-StatementDetails" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/7518d0a66173_9607/ScreenShots-NHProf-StatementDetails_thumb.png" width="1027" height="652"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;2. &lt;strong&gt;Production profiling.&lt;/strong&gt; We now supports profiling production systems, using the HibernatingRhinos.Profiler.Production.dll. If you’re using ASP.NET MVC, you will be able to configure the profiler to use the following route “/profiler” in order to see the profiler interface in your browser. &lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/7518d0a66173_9607/ScreenShots-EFProf-InBrowser_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ScreenShots-EFProf-InBrowser" border="0" alt="ScreenShots-EFProf-InBrowser" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/7518d0a66173_9607/ScreenShots-EFProf-InBrowser_thumb.png" width="1034" height="655"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;3. &lt;strong&gt;Performance.&lt;/strong&gt; We tuned to performance of the profiler and the profiler now it far more responsive. You can run the profiler now for days, and it will still work.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/7518d0a66173_9607/ScreenShots-NHProf-SessionFactoryStatistics_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ScreenShots-NHProf-SessionFactoryStatistics" border="0" alt="ScreenShots-NHProf-SessionFactoryStatistics" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/7518d0a66173_9607/ScreenShots-NHProf-SessionFactoryStatistics_thumb.png" width="1030" height="653"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;4. &lt;strong&gt;Running on the cloud&lt;/strong&gt;. We did some work in order to let you profile your application on Azure. You can profiler your cloud application right from your browser, using the production profiling feature.&lt;/p&gt;     &lt;p&gt;The next post will contains instructions how to run the profiler in a production application, on Azure. &lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/mPAHrivzGIY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/mPAHrivzGIY/whatrsquo-s-new-in-uber-prof-v2-0</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12737/whatrsquo-s-new-in-uber-prof-v2-0?key=209eed97-3a21-4086-90cf-623255bb17df</guid><pubDate>Mon, 03 Dec 2012 07:32:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12737/whatrsquo-s-new-in-uber-prof-v2-0?key=209eed97-3a21-4086-90cf-623255bb17df</feedburner:origLink></item><item><title>Feature explained&amp;ndash;Spatial Geocode from address</title><description>&lt;p&gt;In August we added the option in spatial queries to get the Geocode by address. &lt;/p&gt; &lt;p&gt;We already did something like that in the “Events” page in the RavenDB website and It was quite easy with the Google Maps API.&lt;/p&gt; &lt;p&gt;However when we tried to implement it in the studio we discovered that to do that in Silverlight is not as simple. &lt;/p&gt; &lt;p&gt;Apparently in order to get Google API to work with Silverlight you need to set a bridge server that has the appropriate clientaccesspolicy.xml because the settings on the Google API server does not match the permissions required for Silverlight.&lt;/p&gt; &lt;p&gt;So we looked for another service that has the settings that allowed to work with Silverlight without any complications, what we found is that the Yahoo! Maps Geocoding does just that.&lt;/p&gt; &lt;p&gt;The setting of the Yahoo API was even easier then Google’s and is done like this:&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; height: 243px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; var url = &lt;span style="color: #006080"&gt;"http://where.yahooapis.com/geocode?flags=JC&amp;amp;q="&lt;/span&gt; + queryModel.Address;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;             var webRequest = WebRequest.Create(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Uri(url, UriKind.Absolute));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;             webRequest.GetResponseAsync().ContinueOnSuccessInTheUIThread(doc =&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;             {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;                 RavenJObject jsonData;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (var stream = doc.GetResponseStream())&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;                 {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;                     jsonData = RavenJObject.Load(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JsonTextReader(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; StreamReader(stream)));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;                 }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;                 var result = jsonData[&lt;span style="color: #006080"&gt;"ResultSet"&lt;/span&gt;].SelectToken(&lt;span style="color: #006080"&gt;"Results"&lt;/span&gt;).Values().FirstOrDefault();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (result != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;                 {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;                     queryModel.Latitude = &lt;span style="color: #0000ff"&gt;double&lt;/span&gt;.Parse(result.Value&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color: #006080"&gt;"latitude"&lt;/span&gt;));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;                     queryModel.Longitude = &lt;span style="color: #0000ff"&gt;double&lt;/span&gt;.Parse(result.Value&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color: #006080"&gt;"longitude"&lt;/span&gt;));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;                 }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;             }).Catch();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;As you can see it is simply a web request with a default url with the addition of the address&lt;/p&gt;
&lt;p&gt;For mode information about the Yahoo geocode API: &lt;a title="http://developer.yahoo.com/maps/rest/V1/geocode.html" href="http://developer.yahoo.com/maps/rest/V1/geocode.html"&gt;http://developer.yahoo.com/maps/rest/V1/geocode.html&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/wxfrH1Ed9XA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/wxfrH1Ed9XA/feature-explainedndash-spatial-geocode-from-address</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12706/feature-explainedndash-spatial-geocode-from-address?key=699e38ce-9acb-43cc-ac48-55884873dd4c</guid><pubDate>Tue, 23 Oct 2012 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12706/feature-explainedndash-spatial-geocode-from-address?key=699e38ce-9acb-43cc-ac48-55884873dd4c</feedburner:origLink></item><item><title>New Option in the RavenDB Studio&amp;ndash;Patching</title><description>&lt;p&gt;Not long ago we added the option to do Eval Patching in RavenDB (see: &lt;a title="http://ayende.com/blog/157185/awesome-ravendb-feature-of-the-day-evil-patching" href="http://ayende.com/blog/157185/awesome-ravendb-feature-of-the-day-evil-patching"&gt;http://ayende.com/blog/157185/awesome-ravendb-feature-of-the-day-evil-patching&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;Recently we added this option to the studio.&lt;/p&gt; &lt;p&gt;Now when you open the studio you will see a new tab in the options for “Patch”&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb.png" width="626" height="62"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Once there you will see the next screen:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb_1.png" width="1106" height="575"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;As you can see this page has many options so lets look at them separately&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_6.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb_2.png" width="532" height="63"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;At the top left you have this toolbar with several options, the first one is a combo-box where you can choose what you want to patch (“Document”, “Collection” or “Index”).&lt;/p&gt; &lt;p&gt;Next to it you have the “Test” Option, with this option (which will only be available after selecting a document to check the patch on) when we click on this button the fields on the bottom of the screen (titled “Before Patch” and “After Patch”) will be populated with the selected document and how will it be after we patch.&lt;/p&gt; &lt;p&gt;Next we have the “Save” and “Load” options. With those you can save this page setting and load them again for later use.&lt;/p&gt; &lt;p&gt;Next we have the Patch option that executes the Patch command (this will save the changes to the database) &lt;/p&gt; &lt;p&gt;Let’s look at a small example of patching: &lt;/p&gt; &lt;p&gt;In this case I want to change the Genre name from “Rock” to “Rock and Roll”, after I pressed “Test” I got the screen below, as you can see the “Name” is different.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_12.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb_5.png" width="1101" height="736"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;as you can see on the right of the script we have the “Parameters” list, in there I can do this patch in a different way:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_14.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb_6.png" width="1104" height="746"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Now I as you can see we added another value to the document with the help of parameters.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now lets go over the changes when using “Collection”&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_16.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb_7.png" width="1103" height="742"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In “Collection” you can see that the “Patch” option changed into 2 options: “Patch Selected” and “Patch All”.&lt;/p&gt; &lt;p&gt;In order to patch only some of the items in the collection you can select then in the “Matching Documents”&amp;nbsp; section that was added to the page.&lt;/p&gt; &lt;p&gt;Another thing we have is the option to select on which collection we want to patch.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;And last we have the option to patch by index: &lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_18.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-Option-in-the-RavenDB-StudioPatching_C14D/image_thumb_8.png" width="1109" height="834"&gt;&lt;/a&gt;&lt;/p&gt;        &lt;p&gt;In addition to the changes we had for “Collection” we now have a field “Query” for the index and the patch will apply only to the documents that match this query (and the “Matching Documents” will update accordingly).&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/CBR8wpTFZ7Q" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/CBR8wpTFZ7Q/new-option-in-the-ravendb-studiondash-patching</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12705/new-option-in-the-ravendb-studiondash-patching?key=00e962a5-016c-4879-91b3-fabad389fdf0</guid><pubDate>Mon, 22 Oct 2012 10:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12705/new-option-in-the-ravendb-studiondash-patching?key=00e962a5-016c-4879-91b3-fabad389fdf0</feedburner:origLink></item><item><title>Update in RavenDB: A new statistics page</title><description>&lt;p&gt;Lately we updated the statistics page in RavenDB Studio. &lt;p&gt;This is how the new page looks:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image002_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image002_thumb.jpg" width="225" height="244"&gt;&lt;/a&gt; &lt;p&gt;If you look you can see that the data we see in "Artists" is different than what we see in "AlbumsByCountSold" this is because "Artists" has data on reduce and we want to see that. &lt;p&gt;Another thing we added is the option to view statistics in groups, In the top left you can see a ComboBox in there you can choose from several options: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image003_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image003_thumb.png" width="231" height="234"&gt;&lt;/a&gt; &lt;p&gt;If you select "Single Items" you will see all the data that is not a part of a list: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image004_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image004_thumb.png" width="573" height="256"&gt;&lt;/a&gt; &lt;p&gt;For each index in your database you will see an item in the ComboBox that will show the stats for this index &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image006_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image006_thumb.jpg" width="558" height="368"&gt;&lt;/a&gt; &lt;p&gt;In addition you can view all the indexes. &lt;p&gt;If you have stale indexes another section will be added to the page:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image008_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image008_thumb.jpg" width="558" height="420"&gt;&lt;/a&gt; &lt;p&gt;If you'll press the stale index name you will see the stats for this index.  &lt;p&gt;Another thing we have added is that in the query page if you are using an index (not dynamic query) you can go directly to this index statistics &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image010_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/a4a977183f07_9F20/clip_image010_thumb.jpg" width="558" height="63"&gt;&lt;/a&gt; &lt;p&gt;The most right button will send you to the statistics page with the data for this index displayed.&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/JSsHNP47Iyg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/JSsHNP47Iyg/update-in-ravendb-a-new-statistics-page</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12674/update-in-ravendb-a-new-statistics-page?key=0dc6ff8c-0467-45c0-8ecf-9d01bc8d3969</guid><pubDate>Thu, 13 Sep 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12674/update-in-ravendb-a-new-statistics-page?key=0dc6ff8c-0467-45c0-8ecf-9d01bc8d3969</feedburner:origLink></item><item><title>Temporary Post Used For Theme Detection (ff706e03-16b7-4493-88d4-42456a666959 - 3bfe001a-32de-4114-a6b4-4005b770f6d7)</title><description>&lt;p&gt;This is a temporary post that was not deleted. Please delete this manually. (ba952190-f105-44ee-b525-bd005bea80c8 - 3bfe001a-32de-4114-a6b4-4005b770f6d7)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/uUMGqCESSA4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/uUMGqCESSA4/temporary-post-used-for-theme-detection-ff706e03-16b7-4493-88d4-42456a666959-3bfe001a-32de-4114-a6b4-4005b770f6d7</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12673/temporary-post-used-for-theme-detection-ff706e03-16b7-4493-88d4-42456a666959-3bfe001a-32de-4114-a6b4-4005b770f6d7?key=3519e22b-7296-456d-93e3-cddc8f974c3b</guid><pubDate>Wed, 12 Sep 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12673/temporary-post-used-for-theme-detection-ff706e03-16b7-4493-88d4-42456a666959-3bfe001a-32de-4114-a6b4-4005b770f6d7?key=3519e22b-7296-456d-93e3-cddc8f974c3b</feedburner:origLink></item><item><title>New feature in RavenDB Studio: get spatial geocode from address</title><description>&lt;p&gt;For a while now we had the option to do spatial search, in order to do that we need the longitude and latitude of center we want to search around. &lt;p&gt;However most of the time that we really want to check is result round a specific location (we don’t really care about the longitude and latitude but the address they represent) so usually you would look in some site that you input an address and you get the longitude and latitude. &lt;p&gt;With the new feature in RavenDB Studio we let you enter an address and we update the longitude and latitude for you: &lt;p&gt;The new UI: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-feature-in-RavenDB-Studio-get-spatia_12649/clip_image002_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-feature-in-RavenDB-Studio-get-spatia_12649/clip_image002_thumb.jpg" width="558" height="42"&gt;&lt;/a&gt; &lt;p&gt;We enter an address: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-feature-in-RavenDB-Studio-get-spatia_12649/clip_image004_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-feature-in-RavenDB-Studio-get-spatia_12649/clip_image004_thumb.jpg" width="558" height="43"&gt;&lt;/a&gt; &lt;p&gt;And after we press the "Calculate from address": &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-feature-in-RavenDB-Studio-get-spatia_12649/clip_image006_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/New-feature-in-RavenDB-Studio-get-spatia_12649/clip_image006_thumb.jpg" width="557" height="43"&gt;&lt;/a&gt; &lt;p&gt;It is that simple. &lt;p&gt;In my next post, I’ll discuss exactly how we did it. In turned out that it isn’t as trivial in Silverlight as we might want.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/eoxx0Kq88yE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/eoxx0Kq88yE/new-feature-in-ravendb-studio-get-spatial-geocode-from-address</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12641/new-feature-in-ravendb-studio-get-spatial-geocode-from-address?key=44b00cab-2295-4216-88f8-3244b2a49d6b</guid><pubDate>Wed, 29 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12641/new-feature-in-ravendb-studio-get-spatial-geocode-from-address?key=44b00cab-2295-4216-88f8-3244b2a49d6b</feedburner:origLink></item><item><title>Dealing with conflicts in RavenDB studio</title><description>&lt;p&gt;Recently we added the option to manage bundles in the studio (see &lt;a href="http://blogs.hibernatingrhinos.com/12577/ravendb-1-2-studio-features-the-new-database-wizard"&gt;http://blogs.hibernatingrhinos.com/12577/ravendb-1-2-studio-features-the-new-database-wizard&lt;/a&gt;). &lt;p&gt;One of these bundles is the Replication bundles, sometimes with replication a conflict can happen (this could happen by several reason like 2 or more documents with the same id being created on different destinations), the way RavenDB deals with this is by creating one document to each of the versions available of the document and in the “original” document we have the names of these copies. &lt;p&gt;With the new conflict resolution UI when you try to edit the original document you will receive a suggestion of resolution. &lt;p&gt;Let create a conflict on purpose and see some of the options: &lt;p&gt;In order to create the conflict we will create 2 databases on the same server, both with replication bundle enabled but we will not set the destination yet: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image002_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image002_thumb.jpg" width="315" height="56"&gt;&lt;/a&gt; &lt;p&gt;Now we will create a document on each database with the same Id: &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image004_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image004_thumb.jpg" width="146" height="97"&gt;&lt;/a&gt; &lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image006_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image006_thumb.jpg" width="137" height="109"&gt;&lt;/a&gt; &lt;p&gt;Now we will edit the destinations on the left and connect it to the right : &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image008_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image008_thumb.jpg" width="220" height="156"&gt;&lt;/a&gt; &lt;p&gt;Now we will go to the destination and look the the documents list: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image010_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image010_thumb.jpg" width="358" height="171"&gt;&lt;/a&gt; &lt;p&gt;As you can see we have 3 documents with Id starts with “Example/1”. &lt;p&gt;Now we get to the interesting part if we go and try to edit “Example/1” we will get the next page: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image012_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image012_thumb.jpg" width="485" height="204"&gt;&lt;/a&gt; &lt;p&gt;The Studio realizes that we wanted to edit a document that had a conflict and gave us a suggestion, as long as there are comments on the document you will not be able to save it. &lt;p&gt;Now you can see that RavenDB Studio saw an issue with the Name, we give you a list of all possible names and all you need to do is delete what you don’t want there. &lt;p&gt;Let say we want it to be “Hibernating” we will delete what we don’t want and save: &lt;p&gt;Before save:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image014_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image014" border="0" alt="clip_image014" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image014_thumb.jpg" width="515" height="172"&gt;&lt;/a&gt; &lt;p&gt;After save: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image016_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image016" border="0" alt="clip_image016" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image016_thumb.jpg" width="233" height="179"&gt;&lt;/a&gt; &lt;p&gt;Now if we take a look at the documents list you can see that we are left with just the fixed version: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image018_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image018" border="0" alt="clip_image018" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image018_thumb.jpg" width="404" height="161"&gt;&lt;/a&gt; &lt;p&gt;Now let look what RavenDB will suggest for several other conflicts: &lt;p&gt;&lt;b&gt;Example 2 – Same Item:&lt;/b&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image020_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image020" border="0" alt="clip_image020" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image020_thumb.jpg" width="197" height="112"&gt;&lt;/a&gt; &lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image021_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image021" border="0" alt="clip_image021" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image021_thumb.jpg" width="199" height="114"&gt;&lt;/a&gt; &lt;p&gt;The result: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image023_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image023" border="0" alt="clip_image023" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image023_thumb.jpg" width="521" height="181"&gt;&lt;/a&gt; &lt;p&gt;Notice that we still let you know that a conflict has accrued but you have not comments in there which means you can simply save to resolve the conflict &lt;p&gt;&lt;b&gt;Example 3 – List With Different Items&lt;/b&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image025_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image025" border="0" alt="clip_image025" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image025_thumb.jpg" width="157" height="165"&gt;&lt;/a&gt; &lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image027_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image027" border="0" alt="clip_image027" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image027_thumb.jpg" width="140" height="161"&gt;&lt;/a&gt; &lt;p&gt;The result: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image029_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image029" border="0" alt="clip_image029" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image029_thumb.jpg" width="479" height="202"&gt;&lt;/a&gt; &lt;p&gt;We put both items in the array but add the comment so that the user will know that the data was changed. &lt;p&gt;&lt;b&gt;Example 4 – List with some items the same and some different&lt;/b&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image031_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image031" border="0" alt="clip_image031" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image031_thumb.jpg" width="174" height="144"&gt;&lt;/a&gt; &lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image033_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image033" border="0" alt="clip_image033" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image033_thumb.jpg" width="170" height="144"&gt;&lt;/a&gt; &lt;p&gt;The result:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image035_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image035" border="0" alt="clip_image035" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dealing-with-conflicts-in-RavenDB-studio_E4F4/clip_image035_thumb.jpg" width="457" height="203"&gt;&lt;/a&gt; &lt;p&gt;We combined all the data into one array with no repeats and inform on the change. &lt;p&gt;For more about conflicts read: &lt;a href="https://ravendb.net/docs/server/scaling-out/replication/handling-conflicts"&gt;https://ravendb.net/docs/server/scaling-out/replication/handling-conflicts&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/Fgn2hNUS49M" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/Fgn2hNUS49M/dealing-with-conflicts-in-ravendb-studio</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12609/dealing-with-conflicts-in-ravendb-studio?key=7d9425b0-644b-4bd7-93d1-4967696010c1</guid><pubDate>Mon, 27 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12609/dealing-with-conflicts-in-ravendb-studio?key=7d9425b0-644b-4bd7-93d1-4967696010c1</feedburner:origLink></item><item><title>Creating a Wizard in Silverlight</title><description>&lt;p&gt;When creating the new “Create New Database” for the studio we ran into an issue with showing several child windows one after the other (and keeping in mind that if in one page cancel was click we don’t want to show the next windows) like an install wizard.  &lt;p&gt;Unfortunately Silverlight does not have anything like that so we needed to create on for ourselves. &lt;p&gt;First thing we had in mind when we came to approach this is that Silverlight works asynchronously which means that we want to wait for a page to close before we open the next one. &lt;p&gt;The way we dealt with that was listening to every windows Closed event and on close open the next page (if exists) the Wizard class looks like this: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Creating-a-Wizard-in-Silverlight_BE77/clip_image002_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Creating-a-Wizard-in-Silverlight_BE77/clip_image002_thumb.jpg" width="497" height="432"&gt;&lt;/a&gt; &lt;p&gt;The ShowNext() method will check to see if we have more windows to show and show the next one or return with the result if we are done. &lt;p&gt;We use a TaskCompletionSource and the TPL to make sure that all of that is wrapped in a nice Task, and that is pretty much it. With that done, we can start using it. You can see how easy it is here:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Creating-a-Wizard-in-Silverlight_BE77/clip_image004_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Creating-a-Wizard-in-Silverlight_BE77/clip_image004_thumb.jpg" width="421" height="130"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/oXu9MhvfOlg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/oXu9MhvfOlg/creating-a-wizard-in-silverlight</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12579/creating-a-wizard-in-silverlight?key=df49aae1-1bb1-4402-9852-46bf07f5cb03</guid><pubDate>Fri, 24 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12579/creating-a-wizard-in-silverlight?key=df49aae1-1bb1-4402-9852-46bf07f5cb03</feedburner:origLink></item><item><title>Dynamic Tab View In Silverlight</title><description>&lt;p&gt;With the new “Create New Database” feature to the RanvenDB Studio we added the option to edit your bundles.  &lt;p&gt;We wanted something that seemed to be quite strait forward: A tab view that we could dynamically choose which tabs a visible and which are not.  &lt;p&gt;At first we tried doing it with the TabControl and bind the header visibility of each TabItem to a property in the model that let us know if this database has that bundle.  &lt;p&gt;This is how I had done it:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image002_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image002_thumb.jpg" width="553" height="195"&gt;&lt;/a&gt;  &lt;p&gt;At first it seemed to work, however when looking closely we noticed something like this:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image004_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image004_thumb.jpg" width="234" height="199"&gt;&lt;/a&gt;  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image006_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image006_thumb.jpg" width="132" height="116"&gt;&lt;/a&gt;  &lt;p&gt;As you can see, in the header we only have “Versioning” but the tab we see is the “Quotas Tab”  &lt;p&gt;This happened because we hid the header but the item itself was still the “SelectedItem”.  &lt;p&gt;So we tried to bind the “SelectedItem” as well, but apperantly there is an issue with TabControl and MVVM.  &lt;p&gt;Finally we decided to create our own implementation of Tab View and this is how we did it:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image008_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image008_thumb.jpg" width="527" height="229"&gt;&lt;/a&gt;  &lt;p&gt;In the Model size we have:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image010_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image010_thumb.jpg" width="319" height="202"&gt;&lt;/a&gt;  &lt;p&gt;The Bundles Collection is updated with the list of bundles that are active for this database.  &lt;p&gt;One other this we needed to add was to initialize the SelectedBundle to be the first one in the list.&lt;br&gt;We did that where we initialize the Bundles collection like that:  &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image012_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Dynamic-Tab-View-In-Silverlight_B437/clip_image012_thumb.jpg" width="290" height="230"&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/DZxWl5KeOGk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/DZxWl5KeOGk/dynamic-tab-view-in-silverlight</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12578/dynamic-tab-view-in-silverlight?key=0645dc67-77c2-4dcf-bfbe-e75fe3921fcf</guid><pubDate>Thu, 23 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12578/dynamic-tab-view-in-silverlight?key=0645dc67-77c2-4dcf-bfbe-e75fe3921fcf</feedburner:origLink></item><item><title>RavenDB 1.2 Studio Features: The New Database Wizard</title><description>&lt;p&gt;In the new version of the RavenDB Management Studio we wanted to enhance the options you have, one of these enhancements is the new "Create New Database" wizard. &lt;p&gt;We wanted to add the option to choose bundles for your database, configure various options and in general give you a easy way to control options that you could previously do only if you mastered the zen of RavenDB. &lt;p&gt;Now then you select the New Database option from the databases page you will get the next window: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image002_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image002_thumb.jpg" width="244" height="125"&gt;&lt;/a&gt; &lt;p&gt;If you check the “Advanced Settings” option you will get this window: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image004_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image004_thumb.jpg" width="244" height="129"&gt;&lt;/a&gt; &lt;p&gt;Now you can change the location where the data (path), logs and indexes will be stored.&lt;br&gt;In some cases putting the data, logs and the indexes in different drives can improve performance. &lt;p&gt;On the left side you have the Bundles Selection area, every bundle that you select here will be added to your database. More data about bundles: &lt;a href="https://ravendb.net/docs/server/bundles"&gt;https://ravendb.net/docs/server/bundles&lt;/a&gt; &lt;p&gt;Some of the bundles have settings that you can (and should) configure: &lt;p&gt;&lt;u&gt;Encryption&lt;/u&gt;: &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image006_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image006_thumb.jpg" width="244" height="101"&gt;&lt;/a&gt; &lt;p&gt;In here you can choose you encryption key (or use the random generated on) after the database creation a pop up with the key will show you the key on last time. &lt;b&gt;Make sure you have this key saved somewhere; after that window will close we will not give you the key again.&lt;/b&gt; &lt;p&gt;&lt;u&gt;Quotas Bundle&lt;/u&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image008_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image008_thumb.jpg" width="244" height="194"&gt;&lt;/a&gt; &lt;p&gt;In here you can set the limits for quotas (see &lt;a href="http://ravendb.net/docs/server/bundles/quotas"&gt;http://ravendb.net/docs/server/bundles/quotas&lt;/a&gt;) &lt;p&gt;&lt;u&gt;Replication Bundle&lt;/u&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image010_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image010_thumb.jpg" width="193" height="244"&gt;&lt;/a&gt; &lt;p&gt;In here you can set the replications (and add as many as needed) &lt;br&gt;(see &lt;a href="http://ravendb.net/docs/server/scaling-out/replication"&gt;http://ravendb.net/docs/server/scaling-out/replication&lt;/a&gt;) &lt;p&gt;&lt;u&gt;Versioning&lt;/u&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image012_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image012_thumb.jpg" width="244" height="130"&gt;&lt;/a&gt; &lt;p&gt;In here you can set the versioning (see &lt;a href="http://ravendb.net/docs/server/bundles/versioning"&gt;http://ravendb.net/docs/server/bundles/versioning&lt;/a&gt;) &lt;p&gt;Notice that you can’t remove the default configuration or change the Collection for it but you can edit the values. &lt;p&gt;After you will press “OK” the database will be created (if you have the encryption bundles you will now see the encryption key one last time) &lt;p&gt;If in the future you want to edit the setting to the bundles (for quotas, replication and versioning) you can right-click the database in the databases view and select “edit bundles” &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image014_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image014" border="0" alt="clip_image014" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/Rav.2-Studio-Features-The-New-Database-W_968A/clip_image014_thumb.jpg" width="141" height="82"&gt;&lt;/a&gt; &lt;p&gt;Note: you cannot change which bundles are part of the database after creation.&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/mG4kK3RKfns" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/mG4kK3RKfns/ravendb-1-2-studio-features-the-new-database-wizard</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12577/ravendb-1-2-studio-features-the-new-database-wizard?key=21923ccc-4165-415c-b8db-acb8b4dc6c8b</guid><pubDate>Wed, 22 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12577/ravendb-1-2-studio-features-the-new-database-wizard?key=21923ccc-4165-415c-b8db-acb8b4dc6c8b</feedburner:origLink></item><item><title>Does a blog post have an image?</title><description>&lt;p&gt;Following on my &lt;a href="http://blog.hibernatingrhinos.com/12545/async-and-await-wait-them-all"&gt;previous post&lt;/a&gt;, a different requirement that I may have, is to have a picture for each blog post. I say &lt;em&gt;may&lt;/em&gt; have, because this is how the designer designed the website. In the HTML that I got, each blog post has a picture. But in practice, none of &lt;a href="blog.hibernatingrhinos.com"&gt;Hibernating Rhinos&lt;/a&gt; blog and &lt;a href="http://ayende.com/blog"&gt;Ayende blog&lt;/a&gt; has a picture for each blog item. This is not even a requirement for those blogs. After all, blog posts are all about text, so it perfectly valid to have a blog post without an image.&lt;/p&gt; &lt;p&gt;At fist I thought to just change the design and remove the picture. But than I thought well some of the blog posts do have an image or two in them. What I just parse the blog content and look for an &amp;lt;img /&amp;gt; tags there? I can use them! It may be worth to test this.&lt;/p&gt; &lt;p&gt;A quick search led me to &lt;a href="http://stackoverflow.com/a/138892/257670"&gt;this answer on StackOverflow&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;Based on that, I modified the code in the &lt;a href="http://blog.hibernatingrhinos.com/12545/async-and-await-wait-them-all"&gt;previous post&lt;/a&gt; to the following:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/541d17ea15b8_FD54/RegexImg_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="RegexImg" border="0" alt="RegexImg" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/541d17ea15b8_FD54/RegexImg_thumb.jpg" width="783" height="550"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Very simple. I’ll wait to see how this will behave in practice, with real data. And now I’m thinking that I can even improve this further, be query the actual images pick the best one that match the target dimensions.&lt;/p&gt; &lt;p&gt;I like this too.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/dSO9XbeckC8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/dSO9XbeckC8/does-a-blog-post-have-an-image</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12546/does-a-blog-post-have-an-image?key=277bd60f-46b8-41e7-9a70-4a8fd3eced1d</guid><pubDate>Thu, 16 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12546/does-a-blog-post-have-an-image?key=277bd60f-46b8-41e7-9a70-4a8fd3eced1d</feedburner:origLink></item><item><title>Async await. Wait them All!</title><description>&lt;p&gt;While we’re working on the new website for the company, I had a fair task to complete. The homepage shows two blog posts at the bottom of the page, one from the &lt;a href="http://blog.hibernatingrhinos.com/"&gt;company blog&lt;/a&gt;, which is this blog, and the other from the &lt;a href="http://ayende.com/blog"&gt;ayende blog&lt;/a&gt;. This is a fair task but also interesting. Let’s see why.&lt;/p&gt; &lt;p&gt;Look on the following snippet of code:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Consume(GetLatestBlogPosts message)
{
    var ayendePost = GetLatestBlogPostAsync(&lt;span class="str"&gt;"http://ayende.com/blog/rss"&lt;/span&gt;);
    var companyPost = GetLatestBlogPostAsync(&lt;span class="str"&gt;"http://blog.hibernatingrhinos.com/rss"&lt;/span&gt;);

    Task.WaitAll(ayendePost, companyPost);

    UpdateIfNew(ayendePost.Result, companyPost.Result);
}&lt;/pre&gt;
&lt;p&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/&lt;em&gt;white-space: pre;&lt;/em&gt;/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;/p&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }	&lt;/style&gt;
What it does is very simple. The GetLatestBlogPostAsync method returns a Task&amp;lt;BlogItem&amp;gt; which holds the latest post of the requested blog. I run this against two blogs in order to fetch all latest posts asynchronously, so I use Task.WaitAll in order to wait for the both of the tasks to finish. Than I build a LatestBlogPosts entity, which is like a view model, and put it in the database. See UpdateIfNew method for more details:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UpdateIfNew(BlogPost ayendePost, BlogPost companyPost)
{
    &lt;span class="kwrd"&gt;using&lt;/span&gt; (var session = DocumentStore.OpenSession(DocumentStoreHolder.CompanyWebsite))
    {
        var latestPosts = session.Load&amp;lt;LatestBlogPosts&amp;gt;(LatestBlogPosts.IdConst);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (latestPosts == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        {
            latestPosts = &lt;span class="kwrd"&gt;new&lt;/span&gt; LatestBlogPosts();
            session.Store(latestPosts, LatestBlogPosts.IdConst);
        }

        &lt;span class="kwrd"&gt;if&lt;/span&gt; (latestPosts.Ayende == &lt;span class="kwrd"&gt;null&lt;/span&gt; ||
            latestPosts.Ayende.Title != ayendePost.Title ||
            latestPosts.Ayende.Description != ayendePost.Description)
        {
            latestPosts.Ayende = ayendePost;
        }

        &lt;span class="kwrd"&gt;if&lt;/span&gt; (latestPosts.HibernatingRhinos == &lt;span class="kwrd"&gt;null&lt;/span&gt; ||
            latestPosts.HibernatingRhinos.Title != companyPost.Title ||
            latestPosts.HibernatingRhinos.Description != companyPost.Description)
        {
            latestPosts.HibernatingRhinos = companyPost;
        }

        session.SaveChanges();
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;Courier New&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/&lt;em&gt;white-space: pre;&lt;/em&gt;/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;/p&gt;
&lt;p&gt;This is the code for LatestBlogPosts entity:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; LatestBlogPosts
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; IdConst = &lt;span class="str"&gt;"LatestBlogPosts"&lt;/span&gt;;

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Id { get; set; }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; BlogPost Ayende { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; BlogPost HibernatingRhinos { get; set; }
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; BlogPost
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Title { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Description { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Link { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; PubDate { get; set; }
}&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;courier new&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/&lt;em&gt;white-space: pre;&lt;/em&gt;/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;Now, let proceed to the interesting staff, the implementation of GetLatestBlogPostAsync method. Let recap what it needs to do: download an rss feed and return the first blog item from it.&lt;/p&gt;
&lt;p&gt;My first attempt was the following code:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; HttpClient client = &lt;span class="kwrd"&gt;new&lt;/span&gt; HttpClient();

&lt;span class="kwrd"&gt;public&lt;/span&gt; Task&amp;lt;BlogPost&amp;gt; GetLatestBlogPostAsync(&lt;span class="kwrd"&gt;string&lt;/span&gt; url)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; client.GetAsync(url)
        .ContinueWith(task =&amp;gt;
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (task.IsFaulted || task.Result.StatusCode != HttpStatusCode.OK)
            {
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            }

            &lt;span class="kwrd"&gt;return&lt;/span&gt; task.Result.Content.ReadAsStreamAsync()
                .ContinueWith(task1 =&amp;gt;
                {
                    var xDocument = XDocument.Load(task1.Result);
                    var lastItem = xDocument.Descendants(&lt;span class="str"&gt;"item"&lt;/span&gt;).First();
                    var post = &lt;span class="kwrd"&gt;new&lt;/span&gt; BlogPost
                    {
                        Title = lastItem.Descendants(&lt;span class="str"&gt;"title"&lt;/span&gt;).First().Value,
                        Description = lastItem.Descendants(&lt;span class="str"&gt;"description"&lt;/span&gt;).First().Value,
                        Link = lastItem.Descendants(&lt;span class="str"&gt;"link"&lt;/span&gt;).First().Value,
                        PubDate = lastItem.Descendants(&lt;span class="str"&gt;"pubDate"&lt;/span&gt;).First().Value,
                    };
                    &lt;span class="kwrd"&gt;return&lt;/span&gt; post;
                });
        });
}&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &amp;quot;courier new&amp;quot;, courier, monospace;
	background-color: #ffffff;
	/&lt;em&gt;white-space: pre;&lt;/em&gt;/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;Ah, what a complicated code! And even worth, it does not even compile! Why? I don’t know. But hey, I do not even interested to know. This code looks ugly to me, and I know that I can do better. I’m writing the code in Visual Studio 2012 RC, so I can make a use of the C# 5.0 async and await keywords. Or at least I remember me read so a while ago. So, it is time to try it.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/db912c5dd608_EECF/NotAwaitable_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NotAwaitable" border="0" alt="NotAwaitable" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/db912c5dd608_EECF/NotAwaitable_thumb.jpg" width="639" height="155"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Ah? GetAsync is a not awaitable method. Why? I know that I can use C# 5.0 in order to generate assemblies that targets .NET 4.0, so what the problem is?&lt;/p&gt;
&lt;p&gt;I googled a little bit in order to find out that I need to install the &lt;a href="http://nuget.org/packages/Microsoft.CompilerServices.AsyncTargetingPack"&gt;Microsoft.CompilerServices.AsyncTargetingPack&lt;/a&gt; NuGet package. After I installed it I was able to make a use of the await keyword. (Hah finally! Wish I have knew this before!).&lt;/p&gt;
&lt;p&gt;Now let’s see how the GetLatestBlogPostAsync will look with this?&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/db912c5dd608_EECF/AsyncMethod_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="AsyncMethod" border="0" alt="AsyncMethod" src="http://blog.hibernatingrhinos.com/Images/Windows-Live-Writer/db912c5dd608_EECF/AsyncMethod_thumb.jpg" width="523" height="472"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Well, the code now is much more readable and easy to understand. And hey, it works!&lt;/p&gt;
&lt;p&gt;I like this!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/FGzKf6hwzS0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/FGzKf6hwzS0/async-await-wait-them-all</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12545/async-await-wait-them-all?key=c01bacf5-08e6-4192-950e-40556648bfd9</guid><pubDate>Wed, 15 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12545/async-await-wait-them-all?key=c01bacf5-08e6-4192-950e-40556648bfd9</feedburner:origLink></item><item><title>Implementing a VirtualizingWrapPanel</title><description>&lt;p&gt;This is a guest post by &lt;a href="http://blog.functionalfun.net/"&gt;Samuel Jack&lt;/a&gt;, a freelancer who has worked with us on the new RavenDb Studio features. &lt;p&gt;If you’ve used Silverlight or WPF for any length of time, you will know all about Panels – &lt;em&gt;StackPanel&lt;/em&gt;, &lt;em&gt;DockPanel&lt;/em&gt;, &lt;em&gt;Grid&lt;/em&gt; and the like - which handle the positioning of UI elements on screen. You’ll also know about &lt;em&gt;VirtualizingStackPanel&lt;/em&gt;, which can work wonders for UI performance when displaying substantial lists of data. It does this by deferring the creation of UI elements for off-screen list items until they are scrolled into view. (If you don’t know about Panels, and want to learn, a good place to start is on &lt;a href="http://drwpf.com/blog/2008/02/10/itemscontrol-p-is-for-panel/"&gt;Dr WPF’s blog&lt;/a&gt;) &lt;/p&gt; &lt;p&gt;What if you have a huge stash of data but don’t want to display it in a boring old list? What if you want items laid out like cards on a table? Silverlight and WPF both include a &lt;em&gt;WrapPanel&lt;/em&gt; class which can achieve the desired layout. But as its name suggests, it doesn’t virtualize. Use a &lt;em&gt;WrapPanel&lt;/em&gt; in your 10,000-item &lt;em&gt;ListBox&lt;/em&gt;, and you’ll be twiddling your thumbs whilst it goes off to create elements you might never see.&lt;/p&gt; &lt;p&gt;This was a problem we faced when we were implementing the new data virtualization features in RavenDb Studio 1.2, which lets you scroll through your entire collection of documents. We wanted the card layout, but &lt;em&gt;WrapPanel&lt;/em&gt; wasn’t up to the job of working with huge numbers of items.&lt;/p&gt; &lt;p&gt;So I set about implementing a &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt;, which I’ll share with you today. You can see it in action in our &lt;a href="https://s3.amazonaws.com/demos.seaturtlesoftware/VirtualCollection/VirtualCollectionTestPage.html"&gt;sample Netflix browser&lt;/a&gt; (switch the Display Style to Card). The code is all &lt;a href="https://github.com/samueldjack/VirtualCollection/blob/master/VirtualCollection/VirtualCollection/VirtualizingWrapPanel.cs"&gt;available on GitHub&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;First I’ll give you a quick refresher on how you make &lt;em&gt;ListBox&lt;/em&gt; use a custom Panel, then I’ll run through how one goes about implementing a virtualizing panel in Silverlight.&lt;/p&gt; &lt;h3&gt;A Quick Refresher on Using Panels&lt;/h3&gt; &lt;p&gt;Here’s a snippet of XAML showing a &lt;em&gt;ListBox&lt;/em&gt; using a &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt;:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c190354d-8398-441d-9786-a9dd8a0b4a55" class="wlWriterSmartContent"&gt;&lt;pre style="background-color: #ffffff; overflow: auto"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox &lt;/span&gt;&lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="DocumentsList"&lt;/span&gt;&lt;span style="color: #ff0000"&gt;
                        ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&lt;/span&gt;&lt;span style="color: #808000"&gt;{Binding Items}&lt;/span&gt;&lt;span style="color: #0000ff"&gt;"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; DisplayMember&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Item.Name"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox.Template&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
              &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Border &lt;/span&gt;&lt;span style="color: #ff0000"&gt;CornerRadius&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="2"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; 
                    BorderBrush&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&lt;/span&gt;&lt;span style="color: #808000"&gt;{TemplateBinding BorderBrush}&lt;/span&gt;&lt;span style="color: #0000ff"&gt;"&lt;/span&gt;&lt;span style="color: #ff0000"&gt;
                    BorderThickness&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&lt;/span&gt;&lt;span style="color: #808000"&gt;{TemplateBinding BorderThickness}&lt;/span&gt;&lt;span style="color: #0000ff"&gt;"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
                  &lt;/span&gt;&lt;span style="color: #008000"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color: #008000"&gt; We set the TabNavigation to Cycle on this ScrollViewer to work around a bug which causes the ListBox to loose focus when navigating down (with Down Arrow or Page Down) from the last visible item
              (or even when navigating Up/Down on an item that is only partially visible at the bottom of the screen) &lt;/span&gt;&lt;span style="color: #008000"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
                  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ScrollViewer &lt;/span&gt;&lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="ScrollViewer"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Padding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&lt;/span&gt;&lt;span style="color: #808000"&gt;{TemplateBinding Padding}&lt;/span&gt;&lt;span style="color: #0000ff"&gt;"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="&lt;/span&gt;&lt;span style="color: #808000"&gt;{TemplateBinding Background}&lt;/span&gt;&lt;span style="color: #0000ff"&gt;"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; BorderBrush&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Transparent"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; BorderThickness&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="0"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; 
                                  TabNavigation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Cycle"&lt;/span&gt;&lt;span style="color: #ff0000"&gt; IsTabStop&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="False"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
                      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ItemsPresenter &lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
                  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ScrollViewer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
              &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Border&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox.Template&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox.ItemsPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ItemsPanelTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
            &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;VirtualCollection1:VirtualizingWrapPanel &lt;/span&gt;&lt;span style="color: #ff0000"&gt;ItemWidth&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="200"&lt;/span&gt;&lt;span style="color: #ff0000"&gt;
                                            ItemHeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="230"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
        &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ItemsPanelTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
    &lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox.ItemsPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;
&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListBox&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;The key part is right down at the bottom of the snippet, where we set the &lt;em&gt;ItemsPanel&lt;/em&gt; property of the &lt;em&gt;ListBox&lt;/em&gt;. There we specify an &lt;em&gt;ItemsPanelTemplate&lt;/em&gt; which instantiates the &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt;. Notice that you need to tell the panel how big each item is going to be up front, so that it knows how much room to allow for items which are off screen. 
&lt;p&gt;There’s one other important point. Notice that I’ve overridden the &lt;em&gt;Template&lt;/em&gt; property for the &lt;em&gt;ListBox&lt;/em&gt;. This is so that I can tweak the &lt;em&gt;ScrollViewer&lt;/em&gt; which is going to contain the &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt;. The tweak is a small one: I set its &lt;em&gt;TabNavigation&lt;/em&gt; property to &lt;em&gt;Cycle&lt;/em&gt;. Without this, keyboard navigation doesn’t work properly within the &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt;: under certain circumstances, navigating with the Up/Down or Page Up/Page Down keys would move the keyboard focus out of the &lt;em&gt;ListBox&lt;/em&gt;, rather than to the next item in the &lt;em&gt;ListBox&lt;/em&gt;. &lt;/p&gt;
&lt;h3&gt;Birds-Eye View of a Virtualizing Panel&lt;/h3&gt;
&lt;p&gt;So how do you implement a Virtualizing Panel in Silverlight?&lt;/p&gt;
&lt;p&gt;There’s a post on my own blog which explains how to &lt;a href="http://blog.functionalfun.net/2008/09/how-to-create-gantt-control-in-wpf.html"&gt;create Panels of the standard variety&lt;/a&gt;, and I suggest you go there first for a bit of background. Suffice to say here that normal Panels have one job in life: they must layout the elements given to them by their parent control.&lt;/p&gt;
&lt;p&gt;Virtualizing Panels have two additional responsibilities. First, they must keep track of their own scroll state. And second, they must manage the creation of UI elements - item containers -for each data item as and when they are needed. They don’t actually create the elements – that is done by an ItemContainerGenerator. They just decide when each item container should be generated.&lt;/p&gt;
&lt;p&gt;Implementing a virtualizing panel that can handle UI items of any size you throw at it is a very tricky job. That’s because, in order to accurately position any given element, you need to know the sizes of all the elements that come before it in the list. To know their sizes, you have to measure them, and to be measured, they need to exist. But the very reason for using a virtualizing panel is to avoid creating item unnecessarily. That is why virtualizing panels tend to take one of two easy routes out of the conundrum. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;VirtualizingStackPanel&lt;/em&gt;’s favoured approach is to use index based scrolling, where it only ever shows whole items, and the scroll bar reflects the current items’ indexes in the list and has nothing to do with their sizes. This has the downside of jerky scrolling if you have large items, since each movement of the scrollbar will move previous items entirely out of view.&lt;/p&gt;
&lt;p&gt;Jerky scrolling is avoided by the approach I’ve taken, which is to require that each item displayed by the panel is the same size. This enables us to easily calculate the position of any given item based on its index in the list.&lt;/p&gt;
&lt;h3&gt;Scrolling Responsibilities&lt;/h3&gt;
&lt;p&gt;How does a virtualizing panel discharge its scrolling responsibilities?&lt;/p&gt;
&lt;p&gt;The panel needs to implement &lt;em&gt;IScrollInfo &lt;/em&gt;so its containing ScrollViewer knows that it is going to manage its own scrolling. &lt;em&gt;IScrollInfo’s &lt;/em&gt;job splits into two parts: one is to report on the current scroll state through properties like &lt;em&gt;ExtentHeight&lt;/em&gt; and &lt;em&gt;ViewportWidth&lt;/em&gt;. The Extent represents the logical size of the panel – what it would be if no scrolling was taking place and everything was visible at once. The Viewport is the rectangle of the panel that is actually visible at this moment.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;IScrollInfo&lt;/em&gt;’s other job is to enable that scroll state to be manipulated, through methods like &lt;em&gt;LineUp&lt;/em&gt; and &lt;em&gt;MouseWheelDown&lt;/em&gt;. In many implementations, these manipulation methods all end up by calling one of two other methods on &lt;em&gt;IScrollInfo&lt;/em&gt;, &lt;em&gt;SetVerticalOffset&lt;/em&gt; and &lt;em&gt;SetHorizontalOffset&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Both &lt;em&gt;SetVerticalOffset&lt;/em&gt; and &lt;em&gt;SetHorizontalOffset &lt;/em&gt;do much the same thing, so I’ll just show the &lt;em&gt;SetVerticalOffset&lt;/em&gt; method:&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f2f93460-1032-4ad0-b0de-b69bf961db4e" class="wlWriterSmartContent"&gt;&lt;pre style="background-color: #ffffff; overflow: auto"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt;&lt;span style="color: #000000"&gt; SetVerticalOffset(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt; offset)
{
  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (_isInMeasure)
  {
      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt;;
  }

  offset &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; Clamp(offset, &lt;/span&gt;&lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;, ExtentHeight &lt;/span&gt;&lt;span style="color: #000000"&gt;-&lt;/span&gt;&lt;span style="color: #000000"&gt; ViewportHeight);
  _offset &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; Point(_offset.X, offset);

  InvalidateScrollInfo();
  InvalidateMeasure();
}&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;After checking that the given offset is within the scrollable range, the method simply updates a field to show where the panel is scrolled to. Then it notifies its parent ScrollViewer that its state has changed, and, by calling &lt;em&gt;InvalidateMeasure&lt;/em&gt;, tells the framework that its layout (i.e. the arrangement of its children) needs updating. The method does one other check: if it discovers that the panel is already in the middle of updating its layout (i.e. _&lt;em&gt;isInMeasure&lt;/em&gt; is true) it doesn’t bother changing the scroll offset. This circumvents a problem I’ve encountered where Silverlight tries to scroll to elements newly created during the layout process.&lt;/p&gt;
&lt;h3&gt;Handling Layout&lt;/h3&gt;
&lt;p&gt;Layout happens in two parts. First we measure, calculating how much space the panel will occupy taking into account its children; then we arrange, allocating each child its place within the parent. Measuring happens in &lt;em&gt;MeasureOverride&lt;/em&gt;, and arranging in &lt;em&gt;ArrangeOverride&lt;/em&gt;. Most of the work in the &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt; actually happens in &lt;em&gt;MeasureOverride&lt;/em&gt; because the panel needs to generate items containers before it can measure them. You might wonder why we need to measure the item containers when we’ve already decided that they have a fixed size? That is so that the item containers can handle their own layout, which happens using the same Measure and Arrange process.&lt;/p&gt;
&lt;p&gt;Before I show you the code for &lt;em&gt;MeasureOverride&lt;/em&gt;, here’s an outline of what it does:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;GetExtentInfo&lt;/em&gt; is called to calculate the full height of the list – i.e. how tall it would be if we displayed it all instead of scrolling. 
&lt;li&gt;&lt;em&gt;GetLayoutInfo&lt;/em&gt; then works out, based on the scroll offset, which item indexes fall inside the visible range. We always make sure to include realize one item before the first visible item, and one item after the last visible item. This enables keyboard scrolling to work properly, because Silverlight can then scroll that item into view, thus triggering the panel to realize the rest of the row. 
&lt;li&gt;Any of the current item containers that now fall outside of the visible range are recycled – handed back to the &lt;em&gt;ItemContainerGenerator&lt;/em&gt; so that it can reuse them for other items. 
&lt;li&gt;&lt;em&gt;MeasureOverride&lt;/em&gt; then loops through the visible item indexes and: 
&lt;ol&gt;
&lt;li&gt;Asks the ItemContainerGenerator to create the UI container for the item. If the visibility of the item hasn’t changed, ItemContainerGenerator will give us back the same item container we had before 
&lt;li&gt;Calls &lt;em&gt;SetVirtualItemIndex&lt;/em&gt; to tag the container with the index in the list that it is now representing. This is used in step 3 the next time round when we check for items that fall outside of the visible range. 
&lt;li&gt;Makes sure the container is in the correct place in the Panel’s list of visual children, and thus part of the visual tree. If an item is not in the correct order, keyboard navigation won’t work correctly 
&lt;li&gt;Asks the &lt;em&gt;ItemContainerGenerator&lt;/em&gt; to Prepare the container – apply its styles, etc. 
&lt;li&gt;Measures the item container – this must come after step 4, because until that point the item container isn’t fully initialized, and might not even know what its content is. 
&lt;li&gt;Decide where exactly the item container is going to be displayed: its layout rectangle is recorded in the _&lt;em&gt;childLayouts&lt;/em&gt; dictionary. This is used by the &lt;em&gt;ArrangeOverride&lt;/em&gt; method to arrange each child &lt;/li&gt;&lt;/ol&gt;
&lt;li&gt;Now we can go through the panel’s list of item containers and remove any which were never actually reused. Back in step 3 every existing item container’s VirtualItemIndex tag was set to –1; and in step 4.2, containers which are in use have their tag set to the item of the index they are now representing. So item containers which were never reused will still have a VirtualItemIndex of –1. 
&lt;li&gt;Update the scroll state with the new extent height and viewport size so that scroll bars can be drawn in the correct proportions. 
&lt;li&gt;Decide what size to report as the desired size for the Panel. The Panel wants to take up all the available space (within the confines of its parent), so in most cases, that’s what it reports. But if it is told that the available size is Infinite, then it returns a size of 0, and by convention, Silverlight takes that to mean “use all the available space”. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Here’s the code:&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:fbaea5f9-acb5-421c-b7b9-6f6aed0b8b57" class="wlWriterSmartContent"&gt;&lt;pre style="background-color: #ffffff; overflow: auto"&gt;&lt;span style="color: #0000ff"&gt;protected&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;override&lt;/span&gt;&lt;span style="color: #000000"&gt; Size MeasureOverride(Size availableSize)
{
  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (_itemsControl &lt;/span&gt;&lt;span style="color: #000000"&gt;==&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;&lt;span style="color: #000000"&gt;)
  {
      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; availableSize;
  }
  
  _isInMeasure &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;&lt;span style="color: #000000"&gt;;
  _childLayouts.Clear();

  var extentInfo &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; GetExtentInfo(availableSize, ItemHeight);

  EnsureScrollOffsetIsWithinConstrains(extentInfo);

  var layoutInfo &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; GetLayoutInfo(availableSize, ItemHeight, extentInfo);

  RecycleItems(layoutInfo);

  &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; Determine where the first item is in relation to previously realized items&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;  var generatorStartPosition &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; _itemsGenerator.GeneratorPositionFromIndex(layoutInfo.FirstRealizedItemIndex);

  var visualIndex &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;;

  var currentX &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; layoutInfo.FirstRealizedItemLeft;
  var currentY &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; layoutInfo.FirstRealizedLineTop;

  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt;&lt;span style="color: #000000"&gt; (_itemsGenerator.StartAt(generatorStartPosition, GeneratorDirection.Forward, &lt;/span&gt;&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;&lt;span style="color: #000000"&gt;))
  {
      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt;&lt;span style="color: #000000"&gt; (var itemIndex &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; layoutInfo.FirstRealizedItemIndex; itemIndex &lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;lt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; layoutInfo.LastRealizedItemIndex; itemIndex&lt;/span&gt;&lt;span style="color: #000000"&gt;++&lt;/span&gt;&lt;span style="color: #000000"&gt;, visualIndex&lt;/span&gt;&lt;span style="color: #000000"&gt;++&lt;/span&gt;&lt;span style="color: #000000"&gt;)
      {
          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;&lt;span style="color: #000000"&gt; newlyRealized;

          var child &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; (UIElement)_itemsGenerator.GenerateNext(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;out&lt;/span&gt;&lt;span style="color: #000000"&gt; newlyRealized);
          SetVirtualItemIndex(child, itemIndex);

          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (newlyRealized)
          {
              InsertInternalChild(visualIndex, child);
          }
          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;span style="color: #000000"&gt;
          {
              &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; check if item needs to be moved into a new position in the Children collection&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;              &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (visualIndex &lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000"&gt; Children.Count)
              {
                  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (Children[visualIndex] &lt;/span&gt;&lt;span style="color: #000000"&gt;!=&lt;/span&gt;&lt;span style="color: #000000"&gt; child)
                  {
                      var childCurrentIndex &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; Children.IndexOf(child);

                      &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (childCurrentIndex &lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;)
                      {
                          RemoveInternalChildRange(childCurrentIndex, &lt;/span&gt;&lt;span style="color: #800080"&gt;1&lt;/span&gt;&lt;span style="color: #000000"&gt;);
                      }

                      InsertInternalChild(visualIndex, child);
                  }
              }
              &lt;/span&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;span style="color: #000000"&gt;
              {
                  &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; we know that the child can't already be in the children collection
                  &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; because we've been inserting children in correct visualIndex order,
                  &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; and this child has a visualIndex greater than the Children.Count&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;                  AddInternalChild(child);
              }
          }

          &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; only prepare the item once it has been added to the visual tree&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;          _itemsGenerator.PrepareItemContainer(child);

          child.Measure(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; Size(ItemWidth, ItemHeight));

          _childLayouts.Add(child, &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; Rect(currentX, currentY, ItemWidth, ItemHeight));

          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;&lt;span style="color: #000000"&gt; (currentX &lt;/span&gt;&lt;span style="color: #000000"&gt;+&lt;/span&gt;&lt;span style="color: #000000"&gt; ItemWidth &lt;/span&gt;&lt;span style="color: #000000"&gt;*&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800080"&gt;2&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #000000"&gt;&amp;gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; availableSize.Width)
          {
              &lt;/span&gt;&lt;span style="color: #008000"&gt;//&lt;/span&gt;&lt;span style="color: #008000"&gt; wrap to a new line&lt;/span&gt;&lt;span style="color: #008000"&gt;
&lt;/span&gt;&lt;span style="color: #000000"&gt;              currentY &lt;/span&gt;&lt;span style="color: #000000"&gt;+=&lt;/span&gt;&lt;span style="color: #000000"&gt; ItemHeight;
              currentX &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;;
          }
          &lt;/span&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;span style="color: #000000"&gt;
          {
              currentX &lt;/span&gt;&lt;span style="color: #000000"&gt;+=&lt;/span&gt;&lt;span style="color: #000000"&gt; ItemWidth;
          }
      }
  }

  RemoveRedundantChildren();
  UpdateScrollInfo(availableSize, extentInfo);

  var desiredSize &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt;&lt;span style="color: #000000"&gt; Size(&lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt;.IsInfinity(availableSize.Width) &lt;/span&gt;&lt;span style="color: #000000"&gt;?&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt; : availableSize.Width,
                             &lt;/span&gt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&lt;span style="color: #000000"&gt;.IsInfinity(availableSize.Height) &lt;/span&gt;&lt;span style="color: #000000"&gt;?&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #800080"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt; : availableSize.Height);

  _isInMeasure &lt;/span&gt;&lt;span style="color: #000000"&gt;=&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;&lt;span style="color: #000000"&gt;;

  &lt;/span&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt;&lt;span style="color: #000000"&gt; desiredSize;
}&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;h3&gt;It’s a Wrap&lt;/h3&gt;
&lt;p&gt;That concludes our look at the &lt;em&gt;VirtualizingWrapPanel&lt;/em&gt;. Go and check out the whole sample on &lt;a href="https://github.com/samueldjack/VirtualCollection"&gt;GitHub&lt;/a&gt;, and let us know what you make of it.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/HibernatingRhinos/~4/U3UlpYuvDnI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/HibernatingRhinos/~3/U3UlpYuvDnI/implementing-a-virtualizingwrappanel</link><guid isPermaLink="false">http://blog.hibernatingrhinos.com/12515/implementing-a-virtualizingwrappanel?key=7775d008-763c-467c-84f2-c5ecbfad3f93</guid><pubDate>Tue, 14 Aug 2012 09:00:00 GMT</pubDate><feedburner:origLink>http://blog.hibernatingrhinos.com/12515/implementing-a-virtualizingwrappanel?key=7775d008-763c-467c-84f2-c5ecbfad3f93</feedburner:origLink></item></channel></rss>
