<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><language>en</language><title>Blog posts by Developing is fun</title> <link>https://world.optimizely.com/blogs/developing-is-fun/</link><description></description><ttl>60</ttl><generator>Optimizely World</generator><item> <title>Beginners Guide: Output caching in EPiServer</title>            <link>http://pilpag.blogspot.com/2017/10/beginners-guide-output-caching-in.html</link>            <description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-Csq_p9DGEKc/Weng4XwfEiI/AAAAAAAAIXs/kBy1QYjOtKQUTfQfQ4MckaCsuWPQB4vLwCLcBGAs/s1600/download.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;168&quot; data-original-width=&quot;300&quot; src=&quot;https://1.bp.blogspot.com/-Csq_p9DGEKc/Weng4XwfEiI/AAAAAAAAIXs/kBy1QYjOtKQUTfQfQ4MckaCsuWPQB4vLwCLcBGAs/s1600/download.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Introduction&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;Output caching is not a new concept. There is a variety of project that people try to implement output caching, but how to do it in EpiServer?&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is Output caching?&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;The main purpose of using Output Caching is to dramatically improve the performance of an ASP.NET MVC Application. It enables us to cache the content returned by any controller method so that the same content does not need to be generated each time the same controller method is invoked.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Why using output caching?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;Output Caching has huge advantages,&amp;nbsp;such as:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;*Reduces the load on the server because there is no need to generate the results again&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;* Reduces the load on DB (same reason)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;* Faster response&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;How it is done on MVC?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;OutputCacheAttribute class has been implemented in&amp;nbsp;&lt;/span&gt;&lt;/span&gt;System.Web.Mvc class and can easily being used simply by decorating the Controller with [&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;OutputCache&lt;/span&gt;]&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;. There are different variations for using it, which I am not going to discuss now, but you can read more in &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute(v=vs.118).aspx&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;What is the problem? Lets use it on EpiServer.&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Although&amp;nbsp;&lt;/span&gt;[&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;OutputCache&lt;/span&gt;] attribute works fine for MVC applications, there are some functionalities that are specific to CMS systems. Let me elaborate more with an example:&lt;br /&gt;- You have a page on your CMS and someone tries to view it for the first time. The MVC engine will try to generate the results and then save in in cache.&lt;br /&gt;A second later, another person requests the same exact page. As you&#39;ve guessed the MVC will receive the request and since it has it on its cache, it will respond with the same exact results.&lt;br /&gt;- On the next step the editor change something on the page and publish it, but s(he) will see the same exact results as before since MVC doen&#39;t know about the change and will still return the same response. This also happens for the next people whom request the same page.&lt;br /&gt;&lt;br /&gt;So to summarize we have 2 big problem:&lt;br /&gt;1- content should not be cached for the editors&lt;br /&gt;2- After publishing a page the old cache should be invalidate and the whole process should go through&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;How to fix it?&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;To fix the problems by yourself you need a lot of knowledge about EPiServer and you need some time to implement it. Luckily EPiServer has implemented their own&amp;nbsp;ContentOutputCacheAttribute that will handle those for you :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Simply add&amp;nbsp;ContentOutputCache on top of your action&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt; public class MyPageController : PageController&amp;lt;PageType&amp;gt;&lt;br /&gt; {       &lt;br /&gt;&lt;br /&gt;   [ContentOutputCache(Duration = 3600, VaryByCustom = &quot;*&quot;)]&lt;br /&gt;&lt;br /&gt;   public ActionResult Index(StartPage currentPage)&lt;br /&gt;    {&lt;br /&gt;       ...&lt;br /&gt;    }&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Handle your&amp;nbsp;GetVaryByCustomString in your Global.asax and you are good to go&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt;public class EPiServerApplication : EPiServer.Global&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt; public override string GetVaryByCustomString(HttpContext context, string custom)&lt;br /&gt;    {&lt;br /&gt;       ....&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;What to put into the GetVaryByCustomString depends on your setup, but one simple example could be returning the AbsoluteUri of the page. This way, different pages will differ, language versions will be handled automatically (since the AbsoluteUri will be different regardless of your routing config) but be aware that the personalization will not work since the AbsoluteUri is the same for all different users.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt; public override string GetVaryByCustomString(HttpContext context, string custom)&lt;br /&gt;    {&lt;br /&gt;        return context.Request.Url.AbsoluteUri;&lt;br /&gt;    }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red; font-size: x-large;&quot;&gt;&lt;b style=&quot;background-color: yellow;&quot;&gt;****Very Important!!!!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;ContentOutputCache will not work, unless you have the&amp;nbsp;httpCacheExpiration in your web.config.&lt;br /&gt;&lt;div&gt;Simply go to your webconfig&amp;gt;&lt;/div&gt;&lt;div&gt;configuration&amp;gt;episerver&amp;gt;applicationSettings and make sure that it has properties for&amp;nbsp;httpCacheability and&amp;nbsp;httpCacheExpiration.&lt;br /&gt;&lt;br /&gt;It should be something like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;...&lt;br /&gt;  &amp;lt;episerver&amp;gt;&lt;br /&gt;    &amp;lt;applicationSettings httpCacheability=&quot;Public&quot; httpCacheExpiration=&quot;0:10:00&quot; .... /&amp;gt;&lt;br /&gt;  &amp;lt;/episerver&amp;gt;&lt;br /&gt;....&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2017/10/beginners-guide-output-caching-in.html</guid>            <pubDate>Fri, 20 Oct 2017 13:39:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Beginners Guide: Output caching in EPiServer</title>            <link>http://pilpag.blogspot.com/2017/10/beginners-guide-output-caching-in.html</link>            <description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-Csq_p9DGEKc/Weng4XwfEiI/AAAAAAAAIXs/kBy1QYjOtKQUTfQfQ4MckaCsuWPQB4vLwCLcBGAs/s1600/download.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;168&quot; data-original-width=&quot;300&quot; src=&quot;https://1.bp.blogspot.com/-Csq_p9DGEKc/Weng4XwfEiI/AAAAAAAAIXs/kBy1QYjOtKQUTfQfQ4MckaCsuWPQB4vLwCLcBGAs/s1600/download.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Introduction&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;Output caching is not a new concept. There is a variety of project that people try to implement output caching, but how to do it in EpiServer?&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is Output caching?&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;The main purpose of using Output Caching is to dramatically improve the performance of an ASP.NET MVC Application. It enables us to cache the content returned by any controller method so that the same content does not need to be generated each time the same controller method is invoked.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Why using output caching?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;Output Caching has huge advantages,&amp;nbsp;such as:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;*Reduces the load on the server because there is no need to generate the results again&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;* Reduces the load on DB (same reason)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;* Faster response&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #212121; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;How it is done on MVC?&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;OutputCacheAttribute class has been implemented in&amp;nbsp;&lt;/span&gt;&lt;/span&gt;System.Web.Mvc class and can easily being used simply by decorating the Controller with [&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;OutputCache&lt;/span&gt;]&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;. There are different variations for using it, which I am not going to discuss now, but you can read more in &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute(v=vs.118).aspx&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;font-stretch: normal; line-height: 1.167; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;What is the problem? Lets use it on EpiServer.&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Although&amp;nbsp;&lt;/span&gt;[&lt;span style=&quot;font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;OutputCache&lt;/span&gt;] attribute works fine for MVC applications, there are some functionalities that are specific to CMS systems. Let me elaborate more with an example:&lt;br /&gt;- You have a page on your CMS and someone tries to view it for the first time. The MVC engine will try to generate the results and then save in in cache.&lt;br /&gt;A second later, another person requests the same exact page. As you&#39;ve guessed the MVC will receive the request and since it has it on its cache, it will respond with the same exact results.&lt;br /&gt;- On the next step the editor change something on the page and publish it, but s(he) will see the same exact results as before since MVC doen&#39;t know about the change and will still return the same response. This also happens for the next people whom request the same page.&lt;br /&gt;&lt;br /&gt;So to summarize we have 2 big problem:&lt;br /&gt;1- content should not be cached for the editors&lt;br /&gt;2- After publishing a page the old cache should be invalidate and the whole process should go through&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style=&quot;font-size: large;&quot;&gt;How to fix it?&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;To fix the problems by yourself you need a lot of knowledge about EPiServer and you need some time to implement it. Luckily EPiServer has implemented their own&amp;nbsp;ContentOutputCacheAttribute that will handle those for you :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Simply add&amp;nbsp;ContentOutputCache on top of your action&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt; public class MyPageController : PageController&amp;lt;PageType&amp;gt;&lt;br /&gt; {       &lt;br /&gt;&lt;br /&gt;   [ContentOutputCache(Duration = 3600, VaryByCustom = &quot;*&quot;)]&lt;br /&gt;&lt;br /&gt;   public ActionResult Index(StartPage currentPage)&lt;br /&gt;    {&lt;br /&gt;       ...&lt;br /&gt;    }&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Handle your&amp;nbsp;GetVaryByCustomString in your Global.asax and you are good to go&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt;public class EPiServerApplication : EPiServer.Global&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt; public override string GetVaryByCustomString(HttpContext context, string custom)&lt;br /&gt;    {&lt;br /&gt;       ....&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;What to put into the GetVaryByCustomString depends on your setup, but one simple example could be returning the AbsoluteUri of the page. This way, different pages will differ, language versions will be handled automatically (since the AbsoluteUri will be different regardless of your routing config) but be aware that the personalization will not work since the AbsoluteUri is the same for all different users.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt; public override string GetVaryByCustomString(HttpContext context, string custom)&lt;br /&gt;    {&lt;br /&gt;        return context.Request.Url.AbsoluteUri;&lt;br /&gt;    }&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red; font-size: x-large;&quot;&gt;&lt;b style=&quot;background-color: yellow;&quot;&gt;****Very Important!!!!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;ContentOutputCache will not work, unless you have the&amp;nbsp;httpCacheExpiration in your web.config.&lt;br /&gt;&lt;div&gt;Simply go to your webconfig&amp;gt;&lt;/div&gt;&lt;div&gt;configuration&amp;gt;episerver&amp;gt;applicationSettings and make sure that it has properties for&amp;nbsp;httpCacheability and&amp;nbsp;httpCacheExpiration.&lt;br /&gt;&lt;br /&gt;It should be something like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;...&lt;br /&gt;  &amp;lt;episerver&amp;gt;&lt;br /&gt;    &amp;lt;applicationSettings httpCacheability=&quot;Public&quot; httpCacheExpiration=&quot;0:10:00&quot; .... /&amp;gt;&lt;br /&gt;  &amp;lt;/episerver&amp;gt;&lt;br /&gt;....&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2017/10/beginners-guide-output-caching-in.html</guid>            <pubDate>Fri, 20 Oct 2017 11:39:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Surrounding EpiServer lines with a div in content area</title>            <link>http://pilpag.blogspot.com/2017/02/surrounding-episerver-lines-with-div-in.html</link>            <description>&lt;br /&gt;&lt;h2&gt;Surrounding EpiServer lines with a div in content area&lt;/h2&gt;Some days ago I had a discussion with our frontenders &amp;nbsp;regarding the rows in ContentArea. They liked to have a div surrounding each line of the items so they can make the styles in a correct way. In this small post I will describe what have I done:&lt;br /&gt;I will use Alloy Demo site to describe the issue and my solution&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;b&gt;The problem:&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;In a ContentArea, if you add some items it will be a big div with multiple lines inside.&amp;nbsp;&lt;/div&gt;&lt;div&gt;As you can see in the picture item 1 is taking a line, 2 and 3 are in the second line and 4,5,6 &amp;nbsp;are in the third line. And size of each block depends on their display options.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-i2aXI-LK8w0/WJy2f6-Cy6I/AAAAAAAACok/Ey2mG2b8_X8T0cn1cJ1KxLUrkgD9dYc9QCLcB/s1600/alloy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;296&quot; src=&quot;https://3.bp.blogspot.com/-i2aXI-LK8w0/WJy2f6-Cy6I/AAAAAAAACok/Ey2mG2b8_X8T0cn1cJ1KxLUrkgD9dYc9QCLcB/s640/alloy.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;The request&lt;/h3&gt;&lt;div&gt;Surrounding each line with a div with CssClass=&quot;row&quot; and removing the one for content area.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;The solution&lt;/h3&gt;&lt;div&gt;Removing the css class from the ContentArea is too easy since it has been added to html.Propertyfor in the index page:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-PhoQN5FOhC4/WJy39dMt2XI/AAAAAAAACos/opJ_c5Q5_UAArjlMoB3CFQqv_wRnA471gCLcB/s1600/allo2y.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;38&quot; src=&quot;https://2.bp.blogspot.com/-PhoQN5FOhC4/WJy39dMt2XI/AAAAAAAACos/opJ_c5Q5_UAArjlMoB3CFQqv_wRnA471gCLcB/s640/allo2y.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However to remove add the container around each row, you need to override&amp;nbsp;ContentAreaRenderer. In alloy demo website, it has already been overridden to add suitable classes based on the tags and it is called &amp;nbsp;&amp;nbsp;AlloyContentAreaRenderer. Just override&amp;nbsp;RenderContentAreaItems method and add this code. Then you are good to go :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-Qia-6qAujQE/WJy-L2AakfI/AAAAAAAACo8/0Ois4xYt584oaaxs7IF-NbsKWAsggsaLwCLcB/s1600/alloy4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;432&quot; src=&quot;https://4.bp.blogspot.com/-Qia-6qAujQE/WJy-L2AakfI/AAAAAAAACo8/0Ois4xYt584oaaxs7IF-NbsKWAsggsaLwCLcB/s640/alloy4.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;       protected override void RenderContentAreaItems(HtmlHelper htmlHelper, IEnumerable&lt;contentareaitem&gt; contentAreaItems)&lt;br /&gt;        {&lt;br /&gt;            float totalSize = 0;&lt;br /&gt;            if (contentAreaItems.Any())&lt;br /&gt;                htmlHelper.ViewContext.Writer.Write(@&quot;&lt;div class=&quot;&quot; row=&quot;&quot;&gt;&lt;br /&gt;&quot;);&lt;br /&gt;&lt;br /&gt;            foreach (ContentAreaItem contentAreaItem in contentAreaItems)&lt;br /&gt;            {&lt;br /&gt;                var tag = this.GetContentAreaItemTemplateTag(htmlHelper, contentAreaItem);&lt;br /&gt;                totalSize += GetSize(tag);&lt;br /&gt;                if (totalSize&amp;gt;1)&lt;br /&gt;                {&lt;br /&gt;                    htmlHelper.ViewContext.Writer.Write(@&quot;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;&quot; row=&quot;&quot;&gt;&lt;br /&gt;&quot;);&lt;br /&gt;                    totalSize = GetSize(tag);&lt;br /&gt;                }&lt;br /&gt;                this.RenderContentAreaItem(htmlHelper, contentAreaItem,&lt;br /&gt;                    this.GetContentAreaItemTemplateTag(htmlHelper, contentAreaItem),&lt;br /&gt;                    this.GetContentAreaItemHtmlTag(htmlHelper, contentAreaItem),&lt;br /&gt;                    this.GetContentAreaItemCssClass(htmlHelper, contentAreaItem));&lt;br /&gt;            }&lt;br /&gt;            if (contentAreaItems.Any())&lt;br /&gt;                htmlHelper.ViewContext.Writer.Write(@&quot;&lt;/div&gt;&lt;br /&gt;&quot;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        float GetSize(string tagName)&lt;br /&gt;        {&lt;br /&gt;            if (string.IsNullOrEmpty(tagName))&lt;br /&gt;            {&lt;br /&gt;                return 1f;&lt;br /&gt;            }&lt;br /&gt;            switch (tagName.ToLower())&lt;br /&gt;            {&lt;br /&gt;                case &quot;span12&quot;:&lt;br /&gt;                    return 1f;&lt;br /&gt;                case &quot;span8&quot;:&lt;br /&gt;                    return 0.666666f;&lt;br /&gt;                case &quot;span6&quot;:&lt;br /&gt;                    return 0.5f;&lt;br /&gt;                case &quot;span4&quot;:&lt;br /&gt;                    return 0.333333f;&lt;br /&gt;                default:&lt;br /&gt;                    return 1f;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;/contentareaitem&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3&gt;The result&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-LDUb8EjD7Ns/WJy9vQWwDGI/AAAAAAAACo4/ms9Ic0QvoE4JzwAoG8SwIrDw-C4nIuJOQCLcB/s1600/alloy3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;288&quot; src=&quot;https://3.bp.blogspot.com/-LDUb8EjD7Ns/WJy9vQWwDGI/AAAAAAAACo4/ms9Ic0QvoE4JzwAoG8SwIrDw-C4nIuJOQCLcB/s640/alloy3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2017/02/surrounding-episerver-lines-with-div-in.html</guid>            <pubDate>Thu, 09 Feb 2017 20:12:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Surrounding EpiServer lines with a div in content area</title>            <link>http://pilpag.blogspot.com/2017/02/surrounding-episerver-lines-with-div-in.html</link>            <description>&lt;br /&gt;&lt;h2&gt;Surrounding EpiServer lines with a div in content area&lt;/h2&gt;Some days ago I had a discussion with our frontenders &amp;nbsp;regarding the rows in ContentArea. They liked to have a div surrounding each line of the items so they can make the styles in a correct way. In this small post I will describe what have I done:&lt;br /&gt;I will use Alloy Demo site to describe the issue and my solution&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;b&gt;The problem:&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;In a ContentArea, if you add some items it will be a big div with multiple lines inside.&amp;nbsp;&lt;/div&gt;&lt;div&gt;As you can see in the picture item 1 is taking a line, 2 and 3 are in the second line and 4,5,6 &amp;nbsp;are in the third line. And size of each block depends on their display options.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-i2aXI-LK8w0/WJy2f6-Cy6I/AAAAAAAACok/Ey2mG2b8_X8T0cn1cJ1KxLUrkgD9dYc9QCLcB/s1600/alloy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;296&quot; src=&quot;https://3.bp.blogspot.com/-i2aXI-LK8w0/WJy2f6-Cy6I/AAAAAAAACok/Ey2mG2b8_X8T0cn1cJ1KxLUrkgD9dYc9QCLcB/s640/alloy.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;The request&lt;/h3&gt;&lt;div&gt;Surrounding each line with a div with CssClass=&quot;row&quot; and removing the one for content area.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;The solution&lt;/h3&gt;&lt;div&gt;Removing the css class from the ContentArea is too easy since it has been added to html.Propertyfor in the index page:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-PhoQN5FOhC4/WJy39dMt2XI/AAAAAAAACos/opJ_c5Q5_UAArjlMoB3CFQqv_wRnA471gCLcB/s1600/allo2y.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;38&quot; src=&quot;https://2.bp.blogspot.com/-PhoQN5FOhC4/WJy39dMt2XI/AAAAAAAACos/opJ_c5Q5_UAArjlMoB3CFQqv_wRnA471gCLcB/s640/allo2y.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However to remove add the container around each row, you need to override&amp;nbsp;ContentAreaRenderer. In alloy demo website, it has already been overridden to add suitable classes based on the tags and it is called &amp;nbsp;&amp;nbsp;AlloyContentAreaRenderer. Just override&amp;nbsp;RenderContentAreaItems method and add this code. Then you are good to go :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-Qia-6qAujQE/WJy-L2AakfI/AAAAAAAACo8/0Ois4xYt584oaaxs7IF-NbsKWAsggsaLwCLcB/s1600/alloy4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;432&quot; src=&quot;https://4.bp.blogspot.com/-Qia-6qAujQE/WJy-L2AakfI/AAAAAAAACo8/0Ois4xYt584oaaxs7IF-NbsKWAsggsaLwCLcB/s640/alloy4.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;brush: csharp&quot;&gt;       protected override void RenderContentAreaItems(HtmlHelper htmlHelper, IEnumerable&lt;contentareaitem&gt; contentAreaItems)&lt;br /&gt;        {&lt;br /&gt;            float totalSize = 0;&lt;br /&gt;            if (contentAreaItems.Any())&lt;br /&gt;                htmlHelper.ViewContext.Writer.Write(@&quot;&lt;div class=&quot;&quot; row=&quot;&quot;&gt;&lt;br /&gt;&quot;);&lt;br /&gt;&lt;br /&gt;            foreach (ContentAreaItem contentAreaItem in contentAreaItems)&lt;br /&gt;            {&lt;br /&gt;                var tag = this.GetContentAreaItemTemplateTag(htmlHelper, contentAreaItem);&lt;br /&gt;                totalSize += GetSize(tag);&lt;br /&gt;                if (totalSize&amp;gt;1)&lt;br /&gt;                {&lt;br /&gt;                    htmlHelper.ViewContext.Writer.Write(@&quot;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;&quot; row=&quot;&quot;&gt;&lt;br /&gt;&quot;);&lt;br /&gt;                    totalSize = GetSize(tag);&lt;br /&gt;                }&lt;br /&gt;                this.RenderContentAreaItem(htmlHelper, contentAreaItem,&lt;br /&gt;                    this.GetContentAreaItemTemplateTag(htmlHelper, contentAreaItem),&lt;br /&gt;                    this.GetContentAreaItemHtmlTag(htmlHelper, contentAreaItem),&lt;br /&gt;                    this.GetContentAreaItemCssClass(htmlHelper, contentAreaItem));&lt;br /&gt;            }&lt;br /&gt;            if (contentAreaItems.Any())&lt;br /&gt;                htmlHelper.ViewContext.Writer.Write(@&quot;&lt;/div&gt;&lt;br /&gt;&quot;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        float GetSize(string tagName)&lt;br /&gt;        {&lt;br /&gt;            if (string.IsNullOrEmpty(tagName))&lt;br /&gt;            {&lt;br /&gt;                return 1f;&lt;br /&gt;            }&lt;br /&gt;            switch (tagName.ToLower())&lt;br /&gt;            {&lt;br /&gt;                case &quot;span12&quot;:&lt;br /&gt;                    return 1f;&lt;br /&gt;                case &quot;span8&quot;:&lt;br /&gt;                    return 0.666666f;&lt;br /&gt;                case &quot;span6&quot;:&lt;br /&gt;                    return 0.5f;&lt;br /&gt;                case &quot;span4&quot;:&lt;br /&gt;                    return 0.333333f;&lt;br /&gt;                default:&lt;br /&gt;                    return 1f;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;/contentareaitem&gt;&lt;/pre&gt;&lt;h3&gt;The result&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-LDUb8EjD7Ns/WJy9vQWwDGI/AAAAAAAACo4/ms9Ic0QvoE4JzwAoG8SwIrDw-C4nIuJOQCLcB/s1600/alloy3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;288&quot; src=&quot;https://3.bp.blogspot.com/-LDUb8EjD7Ns/WJy9vQWwDGI/AAAAAAAACo4/ms9Ic0QvoE4JzwAoG8SwIrDw-C4nIuJOQCLcB/s640/alloy3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2017/02/surrounding-episerver-lines-with-div-in.html</guid>            <pubDate>Thu, 09 Feb 2017 19:12:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>EPiServer for beginers, where is version history</title>            <link>http://pilpag.blogspot.com/2016/07/episerver-for-beginers-where-is-version.html</link>            <description>Version history is one of the basic features of any CMS and of course EPiServer has complete support over all of your pages and commerce data.&lt;br /&gt;You might say that everyone knows that EPiServer has this feature, but to be honest I didn&#39;t expect to find it inside the gadgets pane the first time, so I thought why not mentioning it for beginners :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So to see the version history follow these steps:&lt;br /&gt;1- &amp;nbsp;In the editors page find the settings button on top right of your pane.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-8U-PUdW15xg/V4ejGA7MQgI/AAAAAAAAATI/Eu2-VqMA17wUGt1FpmfkjWoExpE5rJNYgCLcB/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-8U-PUdW15xg/V4ejGA7MQgI/AAAAAAAAATI/Eu2-VqMA17wUGt1FpmfkjWoExpE5rJNYgCLcB/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;2- click on add gadgets&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;3- select &quot;versions&quot; gadget from the list&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-gpXaX53a_aY/V4ejGAN6g8I/AAAAAAAAATM/0aFDkbKLsWEGbo_3FRKLUJpV5Q5GQ2sUwCEw/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;255&quot; src=&quot;https://3.bp.blogspot.com/-gpXaX53a_aY/V4ejGAN6g8I/AAAAAAAAATM/0aFDkbKLsWEGbo_3FRKLUJpV5Q5GQ2sUwCEw/s320/2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Version history is available for you. You can see who has done changes to the selected page and if the latest changes has been published or not :)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-tbLogJBUyYY/V4ejGFFQkzI/AAAAAAAAATE/2WgLbzz_B_YlO1QX9tqpcDO7heGEaqL1wCEw/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-tbLogJBUyYY/V4ejGFFQkzI/AAAAAAAAATE/2WgLbzz_B_YlO1QX9tqpcDO7heGEaqL1wCEw/s1600/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2016/07/episerver-for-beginers-where-is-version.html</guid>            <pubDate>Thu, 14 Jul 2016 16:38:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>EpiServer for beginners: How to add custom fields to Order (eCommerce) programatically</title>            <link>http://pilpag.blogspot.com/2016/06/episerver-for-beginners-how-to-add.html</link>            <description>&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some times ago, I had &lt;a href=&quot;http://pilpag.blogspot.dk/2016/03/episerver-for-beginners-how-to-add.html&quot; target=&quot;_blank&quot;&gt;a post about adding a custom field to eCommerce&lt;/a&gt; from the user interface. That post got very popular and some folks like &lt;a href=&quot;https://www.blogger.com/profile/17836903845668223475&quot; rel=&quot;nofollow&quot; style=&quot;background-color: white; color: #888888; font-family: &#39;Trebuchet MS&#39;, Trebuchet, Verdana, sans-serif; font-size: 12px; font-weight: bold; line-height: 16.8px; text-decoration: none;&quot;&gt;Khurram Khan&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/profile/04122782113369262447&quot; rel=&quot;nofollow&quot; style=&quot;background-color: white; color: #888888; font-family: &#39;Trebuchet MS&#39;, Trebuchet, Verdana, sans-serif; font-size: 12px; font-weight: bold; line-height: 16.8px; text-decoration: none;&quot;&gt;Steve C.&lt;/a&gt;&amp;nbsp;mentioned that it is possible to add fields to eCommerce pragmatically. So in this post I will describe how to do it:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Steps&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;1- Create an initialization class&lt;br /&gt;&lt;br /&gt;Create a class, inherit from IInitializableModule, add InitializableModule and ModuleDependency attribute to your class and you are almost there.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp;[InitializableModule]&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; [ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public class Initialization : IInitializableModule&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;* You will need to add &quot;EPiServer.Commerce.Initialization&quot; to have InitializationModule, &quot;EPiServer.Framework&quot; to have&amp;nbsp;InitializableModuleAttribute and &quot;Mediachase.MetaDataPlus.Configurator&quot; to have MetaField methods but of course VS will add them for you when you write the names correctly&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;2- &amp;nbsp;Create the constructor and get the context&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp; public void Initialize(InitializationEngine context)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var mdContext = CatalogContext.MetaDataContext;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;3- Use&amp;nbsp;MetaField.Load to load your field from EPiServer. &lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MetaField.Load(mdContext, name)&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;4- If the result was empty, create the field using&amp;nbsp;MetaField.Create&lt;br /&gt;The structure of the method is like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;MetaField Create(MetaDataContext context, string metaNamespace, string name, string friendlyName, string description, MetaDataType dataType, int length, bool allowNulls, bool multiLanguageValue, bool allowSearch, bool isEncrypted);&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;* just to mention,&amp;nbsp;length&amp;nbsp;is the size of your data, so for example bool is 1, or DateTime is 8&lt;br /&gt;&lt;br /&gt;5- Load the class that you want to add the field to it using &amp;nbsp;MetaClass.Load&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp; var mtClass = MetaClass.Load(mdContext, metaClassName);&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;6- Check if the meta field already exists in the meta class by checking its fields&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp; cls.MetaFields.Contains(field);&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;7- If the meta class doesn&#39;t have the class, add it using AddField&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;mtClass.AddField(field);&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;8- Smile :)&lt;br /&gt;&lt;br /&gt;--------&lt;br /&gt;It is very good idea to have simpler methods for adding fields and joining them to the meta class.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; private MetaField GetOrCreateMetaField(MetaDataContext mdContext, string metaDataNamespace, string name, MetaDataType type, int length, bool allowNulls, bool cultureSpecific)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var f = MetaField.Load(mdContext, name) ??&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MetaField.Create(mdContext, metaDataNamespace, name, name, string.Empty, type, length, allowNulls, cultureSpecific, false, false);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return f;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void JoinField(MetaDataContext mdContext, MetaField field, string metaClassName)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var&amp;nbsp;mtClass&amp;nbsp;= MetaClass.Load(mdContext, metaClassName);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (MetaFieldIsNotConnected(field,&amp;nbsp;mtClass&amp;nbsp;))&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cls.AddField(field);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;* And just to say: it is a good practice to have your strings inside enum classes. If you have a project, but you don&#39;t have any place for your enums and constants, you have to reconsider some of the stuff in your code :)&lt;br /&gt;&lt;br /&gt;The whole code look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&amp;nbsp;[InitializableModule]&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; [ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public class Initialization : IInitializableModule&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; public void Initialize(InitializationEngine context)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MetaDataContext mdContext = CatalogContext.MetaDataContext;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var myField = GetOrCreateMetaField(mdContext, Constants.Metadata.Namespace.Order,&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Extensions.PurchaseOrderExtensions.myFieldName, MetaDataType.DateTime, 8, true, false);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JoinField(mdContext, myField, Constants.Metadata.OrderForm.ClassName);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; private MetaField GetOrCreateMetaField(MetaDataContext mdContext, string metaDataNamespace, string name, MetaDataType type, int length, bool allowNulls, bool cultureSpecific)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var f = MetaField.Load(mdContext, name) ??&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MetaField.Create(mdContext, metaDataNamespace, name, name, string.Empty, type, length, allowNulls, cultureSpecific, false, false);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return f;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void JoinField(MetaDataContext mdContext, MetaField field, string metaClassName)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var&amp;nbsp;mtClass&amp;nbsp;= MetaClass.Load(mdContext, metaClassName);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (MetaFieldIsNotConnected(field,&amp;nbsp;mtClass&amp;nbsp;))&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cls.AddField(field);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private static bool MetaFieldIsNotConnected(MetaField field, MetaClass&amp;nbsp;mtClass&amp;nbsp;)&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&amp;nbsp;mtClass&amp;nbsp;!= null &amp;amp;&amp;amp; !cls.MetaFields.Contains(field);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;A Sample in a project&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;You can look at Steves &amp;nbsp;&lt;strong itemprop=&quot;name&quot;&gt;&lt;a data-pjax=&quot;#js-repo-pjax-container&quot; href=&quot;https://github.com/BVNetwork/CommerceStarterKit&quot; style=&quot;box-sizing: border-box; color: #4078c0; font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, &#39;Apple Color Emoji&#39;, &#39;Segoe UI Emoji&#39;, &#39;Segoe UI Symbol&#39;; line-height: 26px; text-decoration: none;&quot;&gt;CommerceStarterKit&lt;/a&gt;&lt;span style=&quot;color: #666666; font-family: &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;nimbussansl&amp;quot; , &amp;quot;liberationsans&amp;quot; , &amp;quot;freesans&amp;quot; , &amp;quot;clean&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 26px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;and to be more specific, &lt;a href=&quot;https://github.com/BVNetwork/CommerceStarterKit/blob/master/src/web/Business/Initialization/MetadataInitialization.cs&quot; target=&quot;_blank&quot;&gt;this &lt;/a&gt;page :)&lt;/span&gt;&lt;strong itemprop=&quot;name&quot;&gt;&lt;span style=&quot;color: #666666; font-family: &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;nimbussansl&amp;quot; , &amp;quot;liberationsans&amp;quot; , &amp;quot;freesans&amp;quot; , &amp;quot;clean&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 26px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;arial&amp;quot; , sans-serif; white-space: nowrap;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Acknowledgment&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;My gratitude to&amp;nbsp;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;nimbussansl&amp;quot; , &amp;quot;liberationsans&amp;quot; , &amp;quot;freesans&amp;quot; , &amp;quot;clean&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;; font-weight: bold; line-height: 30px;&quot;&gt;Steve Celius&lt;/span&gt;&amp;nbsp;&amp;nbsp;for sharing his code with us.</description>            <guid>http://pilpag.blogspot.com/2016/06/episerver-for-beginners-how-to-add.html</guid>            <pubDate>Mon, 06 Jun 2016 09:48:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>String or binary data would be truncated. EPiServer</title>            <link>http://pilpag.blogspot.com/2016/04/string-or-binary-data-would-be.html</link>            <description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-VMH5trfvOrw/VyM6go2_lwI/AAAAAAAAAI4/JMieaHPSqSs02m6XTt5S2zvLi7ilNzgtQCLcB/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;129&quot; src=&quot;https://3.bp.blogspot.com/-VMH5trfvOrw/VyM6go2_lwI/AAAAAAAAAI4/JMieaHPSqSs02m6XTt5S2zvLi7ilNzgtQCLcB/s640/Untitled.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;I had a stressful story 2 days ago. Well, we were at the end of a sprint and like many other projects enjoyed our peaceful time solving a few minor issues that our customer has reported when suddenly we faced the error:&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;String or binary data would be truncated&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I know what you are thinking:&lt;br /&gt;&quot;Yup! OK, Someone used a name longer than 50 char...&quot;&lt;br /&gt;&lt;br /&gt;But that was not the story!&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;How did I check&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Fortunately, we were at the end of sprint, so I could check all new properties very fast but there was nothing wrong. I&#39;ve checked my DB with a query like the one that I used for finding my string in &lt;a href=&quot;http://pilpag.blogspot.dk/2016/04/search-for-string-in-all-tables-rows.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&amp;nbsp;and checked for strings with len&amp;gt;50. And I&#39;ve shocked since there was nothing wrong.&lt;br /&gt;&lt;br /&gt;Then I&#39;ve asked my good friends in EPiServer to &lt;a href=&quot;/link/329c074be7b742cb9e072d8db266279b.aspx&quot; target=&quot;_blank&quot;&gt;help me&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;/link/5341f632537c4b0ab6b8fb651bd310f8.aspx?userid=9b7dad33-b57b-e011-a4b8-0018717a8c82&quot; style=&quot;background-color: white; border-bottom-style: none; color: #414bfa; font-family: &#39;Simplon Norm&#39;, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 22px; text-decoration: none;&quot;&gt;Quan Mai&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #898b8b; font-family: &amp;quot;simplon norm&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 12px; line-height: 22px;&quot;&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;a href=&quot;/link/5341f632537c4b0ab6b8fb651bd310f8.aspx?userid=87c90252-5047-dd11-93be-0018717a8c82&quot; style=&quot;border-bottom-style: none; color: #414bfa; font-family: &#39;Simplon Norm&#39;, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 22px; text-decoration: none;&quot;&gt;Daniel Ovaska&lt;/a&gt;&amp;nbsp;&lt;/span&gt;guided me how to find the cause of the problem.&lt;br /&gt;&lt;br /&gt;Faithfully, I had a back up from the last night so I could compare it with my working copy easily using &quot;Visual Studio SQL server database comparison tool&quot; that I&#39;ve described in &lt;a href=&quot;http://pilpag.blogspot.dk/2016/04/how-to-compare-2-sql-server-databases.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; :) and found the problem.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;The Problem&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As Quan Mai mentioned, when you have mismatch between your code and your DB, you will have this error. Of course I hopped that the error message were more obvious but just keep that in mind :)&lt;br /&gt;&lt;br /&gt;Anyways, I&#39;ve found the problem! Yayyyyy!&lt;br /&gt;We have 2 totally different branches that we are working on for some time and we have a separated DB for each of them. Then I&#39;ve found the properties of the other one inside my DB....&lt;br /&gt;&lt;br /&gt;Why?&lt;br /&gt;Well if you switch your working branch, it will change the web config, but what you don&#39;t keep your dlls inside your source control, right? So keep in mind to rebuild your code before browsing your site :)&lt;br /&gt;&lt;br /&gt;</description>            <guid>http://pilpag.blogspot.com/2016/04/string-or-binary-data-would-be.html</guid>            <pubDate>Fri, 29 Apr 2016 12:07:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Search for a string in all tables, rows and columns of a DB</title>            <link>http://pilpag.blogspot.com/2016/04/search-for-string-in-all-tables-rows.html</link>            <description>&lt;br /&gt;&lt;br /&gt;Several days ago, I needed to search my database for special string. Then I saw a very good query in &lt;a href=&quot;http://stackoverflow.com/questions/591853/search-for-a-string-in-all-tables-rows-and-columns-of-a-db&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;,&amp;nbsp;but since it wasn&#39;t an article, I thought why not write a small post about it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;type&quot;&gt;DECLARE&lt;/span&gt;&lt;br /&gt;    @&lt;span class=&quot;type&quot;&gt;search_string&lt;/span&gt;  VARCHAR(100),&lt;br /&gt;    @&lt;span class=&quot;type&quot;&gt;table_name&lt;/span&gt;     SYSNAME,&lt;br /&gt;    @&lt;span class=&quot;type&quot;&gt;table_schema&lt;/span&gt;   SYSNAME,&lt;br /&gt;    @&lt;span class=&quot;type&quot;&gt;column_name&lt;/span&gt;    SYSNAME,&lt;br /&gt;    @&lt;span class=&quot;type&quot;&gt;sql_string&lt;/span&gt;     VARCHAR(2000)&lt;br /&gt;&lt;br /&gt;SET @&lt;span class=&quot;type&quot;&gt;search_string&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;string to search&#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;DECLARE&lt;/span&gt; tables_cur CURSOR FOR &lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt; TABLE_SCHEMA, TABLE_NAME &lt;span class=&quot;type&quot;&gt;FROM&lt;/span&gt; INFORMATION_SCHEMA.TABLES &lt;span class=&quot;type&quot;&gt;WHERE&lt;/span&gt; TABLE_TYPE = &lt;span class=&quot;string&quot;&gt;&#39;BASE TABLE&#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;OPEN&lt;/span&gt; tables_cur&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;FETCH&lt;/span&gt; NEXT &lt;span class=&quot;type&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;tables_cur&lt;/span&gt; INTO @&lt;span class=&quot;type&quot;&gt;table_schema&lt;/span&gt;, @&lt;span class=&quot;type&quot;&gt;table_name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;WHILE (@@FETCH_STATUS = 0)&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;BEGIN&lt;/span&gt;&lt;br /&gt;    DECLARE &lt;span class=&quot;type&quot;&gt;columns_cur&lt;/span&gt; CURSOR FOR &lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt; COLUMN_NAME &lt;span class=&quot;type&quot;&gt;FROM&lt;/span&gt; INFORMATION_SCHEMA.COLUMNS &lt;span class=&quot;type&quot;&gt;WHERE&lt;/span&gt; TABLE_SCHEMA = @&lt;span class=&quot;type&quot;&gt;table_schema&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;AND&lt;/span&gt; TABLE_NAME = @&lt;span class=&quot;type&quot;&gt;table_name&lt;/span&gt; AND COLLATION_NAME IS &lt;span class=&quot;type&quot;&gt;NOT&lt;/span&gt; NULL  -- &lt;span class=&quot;type&quot;&gt;Only&lt;/span&gt; strings have &lt;span class=&quot;keyword&quot;&gt;this&lt;/span&gt; and they always have it&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;type&quot;&gt;OPEN&lt;/span&gt; columns_cur&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;type&quot;&gt;FETCH&lt;/span&gt; NEXT &lt;span class=&quot;type&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;columns_cur&lt;/span&gt; INTO @&lt;span class=&quot;type&quot;&gt;column_name&lt;/span&gt;&lt;br /&gt;    WHILE (@@FETCH_STATUS = 0)&lt;br /&gt;    &lt;span class=&quot;type&quot;&gt;BEGIN&lt;/span&gt;&lt;br /&gt;        SET @&lt;span class=&quot;type&quot;&gt;sql_string&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;IF EXISTS (SELECT * FROM &#39;&lt;/span&gt; + QUOTENAME(@&lt;span class=&quot;type&quot;&gt;table_schema&lt;/span&gt;) + &lt;span class=&quot;string&quot;&gt;&#39;.&#39;&lt;/span&gt; + QUOTENAME(@&lt;span class=&quot;type&quot;&gt;table_name&lt;/span&gt;) + &lt;span class=&quot;string&quot;&gt;&#39; WHERE &#39;&lt;/span&gt; + QUOTENAME(@&lt;span class=&quot;type&quot;&gt;column_name&lt;/span&gt;) + &lt;span class=&quot;string&quot;&gt;&#39; LIKE &#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt; + @&lt;span class=&quot;type&quot;&gt;search_string&lt;/span&gt; + &lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;) PRINT &#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt; + QUOTENAME(@&lt;span class=&quot;type&quot;&gt;table_schema&lt;/span&gt;) + &lt;span class=&quot;string&quot;&gt;&#39;.&#39;&lt;/span&gt; + QUOTENAME(@&lt;span class=&quot;type&quot;&gt;table_name&lt;/span&gt;) + &lt;span class=&quot;string&quot;&gt;&#39;, &#39;&lt;/span&gt; + QUOTENAME(@&lt;span class=&quot;type&quot;&gt;column_name&lt;/span&gt;) + &lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        EXECUTE(@&lt;span class=&quot;type&quot;&gt;sql_string&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;type&quot;&gt;FETCH&lt;/span&gt; NEXT &lt;span class=&quot;type&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;columns_cur&lt;/span&gt; INTO @&lt;span class=&quot;type&quot;&gt;column_name&lt;/span&gt;&lt;br /&gt;    END&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;type&quot;&gt;CLOSE&lt;/span&gt; columns_cur&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;type&quot;&gt;DEALLOCATE&lt;/span&gt; columns_cur&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;type&quot;&gt;FETCH&lt;/span&gt; NEXT &lt;span class=&quot;type&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;tables_cur&lt;/span&gt; INTO @&lt;span class=&quot;type&quot;&gt;table_schema&lt;/span&gt;, @&lt;span class=&quot;type&quot;&gt;table_name&lt;/span&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;CLOSE&lt;/span&gt; tables_cur&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;DEALLOCATE&lt;/span&gt; tables_cur&lt;br /&gt;&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This query is very useful, specially when you don&#39;t know about the structure of a project. For instance, you need to check something in a CMS (lets say for debugging your code) like EpiServer but you know nothing about its structure, then finding your values will be a real pain.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>            <guid>http://pilpag.blogspot.com/2016/04/search-for-string-in-all-tables-rows.html</guid>            <pubDate>Tue, 19 Apr 2016 17:17:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Your changes in code won&#39;t take effect?! Check the F@#king Version in your branches!</title>            <link>http://pilpag.blogspot.com/2016/04/your-changes-in-code-wont-take-effect.html</link>            <description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-fLV6bH9YRwc/VwetvOZzxcI/AAAAAAAAAGs/N8imlM-OP0cxvxQDhKC3VrLQffkZVHSEA/s1600/Celty-s-sad-face-anime-13913988-1280-720.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://4.bp.blogspot.com/-fLV6bH9YRwc/VwetvOZzxcI/AAAAAAAAAGs/N8imlM-OP0cxvxQDhKC3VrLQffkZVHSEA/s400/Celty-s-sad-face-anime-13913988-1280-720.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Yesterday I had a lot to do and therefore I had to switch between a lot of different branches. When I was working on one of my tasks I&#39;ve found out that my changes doesn&#39;t take effect on EpiServer. To be more specific, I had a field with a UIHint before, then my UIHint didn&#39;t cause any behavior in the UI! It has been changed to a simple short string field.&lt;br /&gt;&lt;br /&gt;To find the problem I tried adding a new property, but surprisingly my new field didn&#39;t even show up. So I thought maybe something is wrong with my web-server, temp files or etc. I tried restarting my IIS, deleting my temp files everywhere and then restarting IIS again, and after all restarting my windows! But none of them worked!&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-CBWS2i02M2U/VwewHLEh_8I/AAAAAAAAAG4/CwKxlWXKZsEgnK-preEUUh1ArKHPYLYbw/s1600/haveyoutr.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;317&quot; src=&quot;https://4.bp.blogspot.com/-CBWS2i02M2U/VwewHLEh_8I/AAAAAAAAAG4/CwKxlWXKZsEgnK-preEUUh1ArKHPYLYbw/s400/haveyoutr.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;But again I&#39;ve got surprised since even restarting the windows didn&#39;t work for me. So I post a question on&amp;nbsp;&lt;a href=&quot;/link/cd5c3cc09c4641e89aa0ec0c9bf4a4c3.aspx&quot;&gt;EpiServer&lt;/a&gt;&amp;nbsp;and thanks to&amp;nbsp;&lt;a href=&quot;/link/5341f632537c4b0ab6b8fb651bd310f8.aspx?userid=162e74fd-fea9-db11-8952-0018717a8c82&quot;&gt;Per Gunsarfs&lt;/a&gt;&amp;nbsp;I understand what was the problem.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;It was pretty simple! Your changes won&#39;t take effect if there is a newer assembly version available!&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;I just needed to change my assembly version to the newest that we have. (right click on project&amp;gt; properties&amp;gt; application tab&amp;gt; assembly information button) or as I did, update your branch with the parent branch (or master) if it has been set to the latest.&lt;br /&gt;&lt;br /&gt;Easy? Right?! But just if you know it!&lt;br /&gt;&lt;br /&gt;</description>            <guid>http://pilpag.blogspot.com/2016/04/your-changes-in-code-wont-take-effect.html</guid>            <pubDate>Fri, 08 Apr 2016 15:30:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>EPiServer: Your changes in code won&#39;t take effect?! Check the F@#king Version in your branches!</title>            <link>http://pilpag.blogspot.com/2016/04/your-changes-in-code-wont-take-effect.html</link>            <description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-fLV6bH9YRwc/VwetvOZzxcI/AAAAAAAAAGs/N8imlM-OP0cxvxQDhKC3VrLQffkZVHSEA/s1600/Celty-s-sad-face-anime-13913988-1280-720.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://4.bp.blogspot.com/-fLV6bH9YRwc/VwetvOZzxcI/AAAAAAAAAGs/N8imlM-OP0cxvxQDhKC3VrLQffkZVHSEA/s400/Celty-s-sad-face-anime-13913988-1280-720.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Yesterday I had a lot to do and therefore I had to switch between a lot of different branches. When I was working on one of my tasks I&#39;ve found out that my changes doesn&#39;t take effect on EpiServer. To be more specific, I had a field with a UIHint before, then my UIHint didn&#39;t cause any behavior in the UI! It has been changed to a simple short string field.&lt;br /&gt;&lt;br /&gt;To find the problem I tried adding a new property, but surprisingly my new field didn&#39;t even show up. So I thought maybe something is wrong with my web-server, temp files or etc. I tried restarting my IIS, deleting my temp files everywhere and then restarting IIS again, and after all restarting my windows! But none of them worked!&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-CBWS2i02M2U/VwewHLEh_8I/AAAAAAAAAG4/CwKxlWXKZsEgnK-preEUUh1ArKHPYLYbw/s1600/haveyoutr.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;317&quot; src=&quot;https://4.bp.blogspot.com/-CBWS2i02M2U/VwewHLEh_8I/AAAAAAAAAG4/CwKxlWXKZsEgnK-preEUUh1ArKHPYLYbw/s400/haveyoutr.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;But again I&#39;ve got surprised since even restarting the windows didn&#39;t work for me. So I post a question on&amp;nbsp;&lt;a href=&quot;/link/cd5c3cc09c4641e89aa0ec0c9bf4a4c3.aspx&quot;&gt;EpiServer&lt;/a&gt;&amp;nbsp;and thanks to&amp;nbsp;&lt;a href=&quot;/link/5341f632537c4b0ab6b8fb651bd310f8.aspx?userid=162e74fd-fea9-db11-8952-0018717a8c82&quot;&gt;Per Gunsarfs&lt;/a&gt;&amp;nbsp;I understand what was the problem.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;It was pretty simple! Your changes won&#39;t take effect if there is a newer assembly version available!&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;I just needed to change my assembly version to the newest that we have. (right click on project&amp;gt; properties&amp;gt; application tab&amp;gt; assembly information button) or as I did, update your branch with the parent branch (or master) if it has been set to the latest.&lt;br /&gt;&lt;br /&gt;Easy? Right?! But just if you know it!&lt;br /&gt;&lt;br /&gt;</description>            <guid>http://pilpag.blogspot.com/2016/04/your-changes-in-code-wont-take-effect.html</guid>            <pubDate>Fri, 08 Apr 2016 15:30:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Where my block has been used on server? A question that all back-end developer have in mind</title>            <link>http://pilpag.blogspot.com/2016/03/where-my-block-has-been-used-in_28.html</link>            <description>&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;br /&gt;The story started when I had a task to remove old blocks that we don&#39;t use any more. From a back-ender&#39;s point of view, I just needed to find all references in my code and make sure that it has not been used anywhere. But of course it is not correct when dealing with a CMS like EpiServer since they can be used in a ContentArea.&lt;br /&gt;&lt;br /&gt;Yes, I know, we have also [AllowedType] attribute that we use in order to limit contentAreas, but still, there can be some items in blocks tree that has not been used in any page and may cause a problem if an editor click on them.&lt;br /&gt;&lt;br /&gt;So what shall we do?&lt;br /&gt;&lt;br /&gt;First, Every content in EpiServer will be saved in tblContent. if you want to make sure that there is no instance from your typename it is enough to check that table.Code:&lt;br /&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); overflow-x: auto; overflow-y: hidden; padding: 0px; word-wrap: normal;&quot;&gt;&lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt; c.*   FROM [dbo].[tblContent] c&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] ct &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; c.fkContentTypeID = ct.pkID&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt;  [ModelType] like &lt;span class=&quot;string&quot;&gt;&#39;%TypeName%&#39;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;But it is only 10% of the cases, besides where is the fun?!!!&lt;br /&gt;I want to know how many instances of my type exists and where are they now? also I want to know how to find their parent in the tree. So I wrote this code:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); overflow-x: auto; overflow-y: hidden; padding: 0px; word-wrap: normal;&quot;&gt;declare @&lt;span class=&quot;type&quot;&gt;TypeName&lt;/span&gt; nvarchar(50)&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt; @&lt;span class=&quot;type&quot;&gt;TypeName&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;myBlockType&#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;select&lt;/span&gt; tbl2.contentName &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;, tbl2.contentSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentSegment&lt;/span&gt;, tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt;,&lt;br /&gt;con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt; ContainerID,con2&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; ContainerGUID, conLang.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerName&lt;/span&gt;,conLang.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerURLSegment&lt;/span&gt;, contype.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerTypeName&lt;/span&gt;, &lt;br /&gt;contype.ModelType &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerModelType&lt;/span&gt;, con2.fkParentID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainersParentId&lt;/span&gt;, conContainerParentLanguage.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;, conContainerParentType.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;from [dbo].[tblContentProperty] cp  &lt;br /&gt; &lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join &lt;br /&gt;(&lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt;  c.*, cl.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;,  cl.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentSegment&lt;/span&gt; FROM [dbo].[tblContent] c&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] ct &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; c.fkContentTypeID = ct&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage cL &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cL.fkContentID = c.&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt;  ct.&lt;span class=&quot;type&quot;&gt;Name&lt;/span&gt; like @&lt;span class=&quot;type&quot;&gt;TypeName&lt;/span&gt;)  tbl2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cp.&lt;span class=&quot;type&quot;&gt;LongString&lt;/span&gt; like &lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;+cast( tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;nvarchar&lt;/span&gt;(50))+&lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join tblContent con2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.pkID = cp.fkContentID&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] contype &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.fkContentTypeID = contype&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conLang &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conLang.fkContentID = con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContent conContainerParent &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.pkID = con2&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;br /&gt;inner join tblContentType conContainerParentType &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.fkContentTypeID = conContainerParentType&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conContainerParentLanguage &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParentLanguage.fkContentID = con2.&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;This code will show you all instances of a type, and where they have been contained including typename and the address that we can find the parent in the tree.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The result will be something like this&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-UIxjs7PzCuk/VuqTAPHiYsI/AAAAAAAAAEo/TMUkUJWHdWM1FBRP2hwpN17qnKzWgn4gg/s1600/contentPlaceBaseOnType.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;177&quot; src=&quot;https://1.bp.blogspot.com/-UIxjs7PzCuk/VuqTAPHiYsI/AAAAAAAAAEo/TMUkUJWHdWM1FBRP2hwpN17qnKzWgn4gg/s640/contentPlaceBaseOnType.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But wait a minute! what if I can&#39;t find the container it self?!&lt;br /&gt;Well, that is easy :) &amp;nbsp;the query is 90% the same, but we just need to search for the contentId (instance) instead of the type name.&lt;br /&gt;Of course if you search for the containers type name, you will eventually find it, But it is easier to change 2 lines of code :)&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); overflow-x: auto; overflow-y: hidden; padding: 0px; word-wrap: normal;&quot;&gt;declare @&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; nvarchar(50)&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt; @&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;B6845FFC-5475-4FC3-C701-5A5D6FD5F967&#39;&lt;/span&gt; -- &lt;span class=&quot;type&quot;&gt;put&lt;/span&gt; you content GUID &lt;span class=&quot;keyword&quot;&gt;in&lt;/span&gt; here &lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;select&lt;/span&gt; tbl2.contentName &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;, tbl2.contentSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentSegment&lt;/span&gt;, tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt;,&lt;br /&gt;con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt; ContainerID,con2&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; ContainerGUID, conLang.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerName&lt;/span&gt;,conLang.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerURLSegment&lt;/span&gt;, contype.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerTypeName&lt;/span&gt;, &lt;br /&gt;contype.ModelType &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerModelType&lt;/span&gt;, con2.fkParentID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainersParentId&lt;/span&gt;, conContainerParentLanguage.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;, conContainerParentType.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;from [dbo].[tblContentProperty] cp&lt;br /&gt; &lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join&lt;br /&gt;(&lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt;  c.*, cl.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;,  cl.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentSegment&lt;/span&gt;&lt;br /&gt;FROM [dbo].[tblContent] &lt;span class=&quot;type&quot;&gt;c&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage cL &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cL.fkContentID = &lt;span class=&quot;type&quot;&gt;c&lt;/span&gt;.&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt; c.&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; like @&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt;)  tbl2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cp.&lt;span class=&quot;type&quot;&gt;LongString&lt;/span&gt; like &lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;+cast( tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;nvarchar&lt;/span&gt;(50))+&lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join tblContent con2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.pkID = cp.fkContentID&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] contype &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.fkContentTypeID = contype&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conLang &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conLang.fkContentID = con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContent conContainerParent &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.pkID = con2&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;br /&gt;inner join tblContentType conContainerParentType &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.fkContentTypeID = conContainerParentType&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conContainerParentLanguage &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParentLanguage.fkContentID = con2.&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/where-my-block-has-been-used-in_28.html</guid>            <pubDate>Mon, 28 Mar 2016 14:59:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Where my block has been used in production server? A question that all back-end developer have in mind.</title>            <link>http://pilpag.blogspot.com/2016/03/where-my-block-has-been-used-in.html</link>            <description>&lt;div class=&quot;csharpcode&quot;&gt;&lt;br /&gt;&lt;br /&gt;The story started when I had a task to remove old blocks that we don&#39;t use any more. From a back-ender&#39;s point of view, I just needed to find all references in my code and make sure that it has not been used anywhere. But of course it is not correct when dealing with a CMS like EpiServer since they can be used in a ContentArea.&lt;br /&gt;&lt;br /&gt;Yes, I know, we have also [AllowedType] attribute that we use in order to limit contentAreas, but still, there can be some items in blocks tree that has not been used in any page and may cause a problem if an editor click on them.&lt;br /&gt;&lt;br /&gt;So what shall we do?&lt;br /&gt;&lt;br /&gt;First, Every content in EpiServer will be saved in tblContent. if you want to make sure that there is no instance from your typename it is enough to check that table.Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt; c.*   FROM [dbo].[tblContent] c&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] ct &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; c.fkContentTypeID = ct.pkID&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt;  [ModelType] like &lt;span class=&quot;string&quot;&gt;&#39;%TypeName%&#39;&lt;/span&gt;&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;But it is only 10% of the cases, besides where is the fun?!!!&lt;br /&gt;I want to know how many instances of my type exists and where are they now? also I want to know how to find their parent in the tree. So I wrote this code:&lt;br /&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;declare @&lt;span class=&quot;type&quot;&gt;TypeName&lt;/span&gt; nvarchar(50)&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt; @&lt;span class=&quot;type&quot;&gt;TypeName&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;myBlockType&#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;select&lt;/span&gt; tbl2.contentName &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;, tbl2.contentSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentSegment&lt;/span&gt;, tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt;,&lt;br /&gt;con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt; ContainerID,con2&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; ContainerGUID, conLang.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerName&lt;/span&gt;,conLang.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerURLSegment&lt;/span&gt;, contype.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerTypeName&lt;/span&gt;, &lt;br /&gt;contype.ModelType &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerModelType&lt;/span&gt;, con2.fkParentID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainersParentId&lt;/span&gt;, conContainerParentLanguage.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;, conContainerParentType.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;from [dbo].[tblContentProperty] cp  &lt;br /&gt; &lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join &lt;br /&gt;(&lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt;  c.*, cl.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;,  cl.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentSegment&lt;/span&gt; FROM [dbo].[tblContent] c&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] ct &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; c.fkContentTypeID = ct&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage cL &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cL.fkContentID = c.&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt;  ct.&lt;span class=&quot;type&quot;&gt;Name&lt;/span&gt; like @&lt;span class=&quot;type&quot;&gt;TypeName&lt;/span&gt;)  tbl2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cp.&lt;span class=&quot;type&quot;&gt;LongString&lt;/span&gt; like &lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;+cast( tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;nvarchar&lt;/span&gt;(50))+&lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join tblContent con2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.pkID = cp.fkContentID&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] contype &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.fkContentTypeID = contype&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conLang &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conLang.fkContentID = con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContent conContainerParent &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.pkID = con2&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;br /&gt;inner join tblContentType conContainerParentType &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.fkContentTypeID = conContainerParentType&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conContainerParentLanguage &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParentLanguage.fkContentID = con2.&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;br /&gt;&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;This code will show you all instances of a type, and where they have been contained including typename and the address that we can find the parent in the tree.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The result will be something like this&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-UIxjs7PzCuk/VuqTAPHiYsI/AAAAAAAAAEo/TMUkUJWHdWM1FBRP2hwpN17qnKzWgn4gg/s1600/contentPlaceBaseOnType.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;177&quot; src=&quot;https://1.bp.blogspot.com/-UIxjs7PzCuk/VuqTAPHiYsI/AAAAAAAAAEo/TMUkUJWHdWM1FBRP2hwpN17qnKzWgn4gg/s640/contentPlaceBaseOnType.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But wait a minute! what if I can&#39;t find the container it self?!&lt;br /&gt;Well, that is easy :) &amp;nbsp;the query is 90% the same, but we just need to search for the contentId (instance) instead of the type name.&lt;br /&gt;Of course if you search for the containers type name, you will eventually find it, But it is easier to change 2 lines of code :)&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;declare @&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; nvarchar(50)&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt; @&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;B6845FFC-5475-4FC3-C701-5A5D6FD5F967&#39;&lt;/span&gt; -- &lt;span class=&quot;type&quot;&gt;put&lt;/span&gt; you content GUID &lt;span class=&quot;keyword&quot;&gt;in&lt;/span&gt; here &lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;select&lt;/span&gt; tbl2.contentName &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;, tbl2.contentSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentSegment&lt;/span&gt;, tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt;,&lt;br /&gt;con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt; ContainerID,con2&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; ContainerGUID, conLang.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerName&lt;/span&gt;,conLang.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerURLSegment&lt;/span&gt;, contype.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerTypeName&lt;/span&gt;, &lt;br /&gt;contype.ModelType &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerModelType&lt;/span&gt;, con2.fkParentID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainersParentId&lt;/span&gt;, conContainerParentLanguage.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;, conContainerParentType.Name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;ContainerParentName&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;from [dbo].[tblContentProperty] cp&lt;br /&gt; &lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join&lt;br /&gt;(&lt;span class=&quot;type&quot;&gt;SELECT&lt;/span&gt;  c.*, cl.name &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentName&lt;/span&gt;,  cl.URLSegment &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;contentSegment&lt;/span&gt;&lt;br /&gt;FROM [dbo].[tblContent] &lt;span class=&quot;type&quot;&gt;c&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage cL &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cL.fkContentID = &lt;span class=&quot;type&quot;&gt;c&lt;/span&gt;.&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt; c.&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt; like @&lt;span class=&quot;type&quot;&gt;ContentGUID&lt;/span&gt;)  tbl2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; cp.&lt;span class=&quot;type&quot;&gt;LongString&lt;/span&gt; like &lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;+cast( tbl2.ContentGUID &lt;span class=&quot;keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;nvarchar&lt;/span&gt;(50))+&lt;span class=&quot;string&quot;&gt;&#39;%&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join tblContent con2 &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.pkID = cp.fkContentID&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;inner&lt;/span&gt; join [dbo].[tblContentType] contype &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; con2.fkContentTypeID = contype&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conLang &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conLang.fkContentID = con2&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContent conContainerParent &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.pkID = con2&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;br /&gt;inner join tblContentType conContainerParentType &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParent.fkContentTypeID = conContainerParentType&lt;span class=&quot;type&quot;&gt;pkID&lt;/span&gt;&lt;br /&gt;inner join tblContentLanguage conContainerParentLanguage &lt;span class=&quot;type&quot;&gt;on&lt;/span&gt; conContainerParentLanguage.fkContentID = con2.&lt;span class=&quot;type&quot;&gt;fkParentID&lt;/span&gt;&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/where-my-block-has-been-used-in.html</guid>            <pubDate>Tue, 22 Mar 2016 11:30:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Agile Software Development: Are we really equal?</title>            <link>http://pilpag.blogspot.com/2016/03/agile-software-development-are-we.html</link>            <description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-mrAtu19MvQk/VvBz_JRN8yI/AAAAAAAAAE4/shiaiVcRVaAfY5ffb_OeQ5kWUkuS49q2A/s1600/agile.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;197&quot; src=&quot;https://1.bp.blogspot.com/-mrAtu19MvQk/VvBz_JRN8yI/AAAAAAAAAE4/shiaiVcRVaAfY5ffb_OeQ5kWUkuS49q2A/s320/agile.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;When people talk about agile process like Scrum, it is pretty normal to hear that there is no job title like architect or programmer, etc. so many will think that as a &quot;developer&quot; or a&quot;team member&quot; everyone has to be equal. Well :) if you think the same, you are wrong.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Agile process&#39; usually define for a small teams (like 4-9 team members) so it is understandable to expect people to have some common knowledge, but of course that doesn&#39;t mean that you are equal even if the whole team works in a same department.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here I want to share some of my personal experiences with you:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;&lt;b&gt;Personal Experiences&lt;/b&gt;&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-24o-UQVNuX8/VvB9DwPR48I/AAAAAAAAAFI/30ma2nyvyS8pfvnvk9w-Y6zqVkOh1PMTA/s1600/PersonalExperience.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;152&quot; src=&quot;https://2.bp.blogspot.com/-24o-UQVNuX8/VvB9DwPR48I/AAAAAAAAAFI/30ma2nyvyS8pfvnvk9w-Y6zqVkOh1PMTA/s320/PersonalExperience.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is very important to recognize the individual in the team. Each person has some special abilities and came from different background, We all write software systems but even on a single project, we have different tasks so it is clear that each one looks at the task from different aspect.&lt;/div&gt;&lt;div&gt;When team needs to take a decision about an issue, it is important that all attend the meeting and share their ideas, but it is predictable that someone who has some background will have more to discuss. More importantly it doesn&#39;t mean that you have to convince everyone that the idea is great. Of course if your team members are mature enough, they won&#39;t insist much to choose the easy way when the ones with more experience already chosen another one or vise versa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As an example, I was working in a very good team and all members were senior developers and we used scrum. When there was a discussion about structure or architecture, it was people with architecture background who discussed the ideas mostly, but of course everyone shared their ideas and tries their best to improve the solution. After some discussions, sometimes one or 2 didn&#39;t convince totally but since we know each other, we just trust on the solution on experts.&lt;/div&gt;&lt;h4&gt;&lt;/h4&gt;&lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;The role of a &quot;dean&quot;&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-9kpLbviDpyc/VvCD47HQurI/AAAAAAAAAFY/ijzwqM4tlTQLKbdq71HiunbQ5ctGDu8Mg/s1600/master_oogway_by_dillon619-d50xchr.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://2.bp.blogspot.com/-9kpLbviDpyc/VvCD47HQurI/AAAAAAAAAFY/ijzwqM4tlTQLKbdq71HiunbQ5ctGDu8Mg/s320/master_oogway_by_dillon619-d50xchr.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;On a daily basis, a normal team can handle most situations. But there are some times that you need to ask someone to help you choose. I want to emphasis on that there is no boss or things like that in the team and when I refer to dean I don&#39;t mean someone that is superior to others in any aspect, I specially believe that a software team has to be flat and everyone has to be responsible for what he do. So what does it mean to have a dean?!&lt;br /&gt;A dean is someone whom you trust, with his judgment. It doesn&#39;t even mean that the one has more knowledge than you.&lt;br /&gt;&lt;div&gt;For instance, we had a small project and we had to implement a service with lots of needs. The 3 of us researched for 2 weeks and discussed the solution almost everyday. After all, we could&#39;t agree on a single result since there was different possible scenarios. Then we explained everything to the one and asked him to choose between our solution.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;Bug Ratio and &quot;Blame&quot; tools&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-mzsmTFPEB_Q/VvCJuDkzKHI/AAAAAAAAAFo/1MC0x4wNbnkmXk9yPnRASAYnCQakVLFSg/s1600/blame.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;303&quot; src=&quot;https://2.bp.blogspot.com/-mzsmTFPEB_Q/VvCJuDkzKHI/AAAAAAAAAFo/1MC0x4wNbnkmXk9yPnRASAYnCQakVLFSg/s320/blame.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is really important to know that we don&#39;t blame people for their code! Because we all know that as humans we all make mistakes and more importantly as a team we have to support each other, not to blame each other, So how can we use the blame tool? (as git called)&lt;/div&gt;&lt;div&gt;Believe it or not, we know each other when we work together for a portion of time and we use this knowledge to understand why someone did something. To be more specific what is your reaction when you have to change an old code and you think it is not efficient, or it is not what you think it has to be?&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;* If you simply change it to what you think is correct, or you afraid of changing it at all then you need to gain more experience, please don&#39;t change anything and ask someone with more experience to work in pair with you for some time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I normally try to understand the method, what it does, why the one implemented it like that and where it has been used, If I still believe that it is not good and I want to change it, I will check the history line by line using blame tool to understand the process of change and to define the owner. If the code has been changed dramatically by time, or if the owner is someone with normal bug rate, I will refactor the code immediately. But if the code has been written by someone who has low bug rate, (someone who maybe has a clue about the future) I will talk to him first, because it is probable that he knows something that I missed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/agile-software-development-are-we.html</guid>            <pubDate>Tue, 22 Mar 2016 00:54:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>EpiServer for beginners: How to add custom fields to Order (eCommerce)</title>            <link>http://pilpag.blogspot.com/2016/03/episerver-for-beginners-how-to-add.html</link>            <description>&lt;h3&gt;Introduction&lt;/h3&gt;One of the simplest things that any developer would want is to add some fields to Order table or in related ones. When dealing with content pages, it would be handled automatically using Code-First methodology. But in the eCommerce system you have to do some steps.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Example&lt;/h3&gt;When you are dealing with external systems, you will need to have their Id in your system and since it is related to your order, well it is not a good idea to put in somewhere else.&lt;br /&gt;Also, you may want to add external fields like status or etc to your order.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Steps&lt;/h3&gt;&lt;h4&gt;steps in Ecommerce&lt;/h4&gt;1- Go to Commerce Manager&amp;gt; Administration &amp;gt;Meta fields&amp;gt; New Meta Field&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-J9Ee_Q8vZPU/VufKTm5FDSI/AAAAAAAAADg/n-SjjqIKd7UtFhD9g6QY5p-7ANxB3Qzqg/s1600/commerce.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;189&quot; src=&quot;https://3.bp.blogspot.com/-J9Ee_Q8vZPU/VufKTm5FDSI/AAAAAAAAADg/n-SjjqIKd7UtFhD9g6QY5p-7ANxB3Qzqg/s320/commerce.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;2- Fill name and friendly name and choose type of your field. Then choose properties like search option as you need. just have in mind that changing allow null field would be hard.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-4WyaYJJliis/VufLALPLmPI/AAAAAAAAADo/uXOciMMJToAZqo-nHXTHb8Dhnwi7aDRmA/s1600/commerce2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;274&quot; src=&quot;https://2.bp.blogspot.com/-4WyaYJJliis/VufLALPLmPI/AAAAAAAAADo/uXOciMMJToAZqo-nHXTHb8Dhnwi7aDRmA/s320/commerce2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;In these 2 steps, you&#39;ve created a field in your order. Now you have to assign it to any table that you need.&lt;br /&gt;3- &amp;nbsp;Go to meta classes right under order systems and select the main table(element) that you want to add your field. For instance, I want to add my field to my order form.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-s3D64pNXE5w/VufMKcVVMDI/AAAAAAAAAD0/xBDI4iSHE7kWH2zwopg5iHl56JCj1BQ0g/s1600/ecommerce%2B3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;119&quot; src=&quot;https://2.bp.blogspot.com/-s3D64pNXE5w/VufMKcVVMDI/AAAAAAAAAD0/xBDI4iSHE7kWH2zwopg5iHl56JCj1BQ0g/s320/ecommerce%2B3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;4- Now select the related external table related to that element. For order from it is only one, but it differs from element to element.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-k6jyri9mfPQ/VufNMrFFiPI/AAAAAAAAAD8/NsTedPD4KaUNfL0sPlTEMYnQe_RsXx12Q/s1600/ecommerce4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;142&quot; src=&quot;https://3.bp.blogspot.com/-k6jyri9mfPQ/VufNMrFFiPI/AAAAAAAAAD8/NsTedPD4KaUNfL0sPlTEMYnQe_RsXx12Q/s320/ecommerce4.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;5- Select your field and click &quot;OK&quot;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Steps in your code&lt;/h4&gt;&lt;div&gt;We have our field in our DB now.It is very easy to use it in your code.&lt;/div&gt;&lt;div&gt;The easiest way is to write a code like this line for setting the field:&lt;/div&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt; order.OrderForms[0][&lt;span class=&quot;string&quot;&gt;&quot;MyFieldsName&quot;&lt;/span&gt;] = &lt;span class=&quot;keyword&quot;&gt;value&lt;/span&gt;;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And Like this one to Getting it (for strings):&lt;/div&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; x=order.OrderForms[0][&lt;span class=&quot;string&quot;&gt;&quot;MyFieldsName&quot;&lt;/span&gt;].ToString();&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But It is always good to have a class, that contains names and methods for handling fields and their names.&lt;br /&gt;Use Constants to avoid writing wrong names. Also set and get all fields in the same class so you have them centralized and use those methods.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt; &lt;span class=&quot;keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; MyFieldName = &lt;span class=&quot;string&quot;&gt;&quot;MyFieldName&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; GetMyField()&lt;br /&gt;{&lt;br /&gt;   &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; order.OrderForms[0][MyFieldName].ToString();        &lt;br /&gt;}&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt;Edit:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I wrote a post in &lt;a href=&quot;http://pilpag.blogspot.dk/2016/06/episerver-for-beginners-how-to-add.html&quot; target=&quot;_blank&quot;&gt;here&amp;nbsp;&lt;/a&gt;&amp;nbsp;describing how to add the field grammatically.&lt;br /&gt;&lt;br /&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/episerver-for-beginners-how-to-add.html</guid>            <pubDate>Tue, 15 Mar 2016 10:07:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>A simple queue for EpiServer</title>            <link>http://pilpag.blogspot.com/2016/03/a-simple-queue-for-episerver.html</link>            <description>&lt;span style=&quot;font-size: large;&quot;&gt;Intro&lt;/span&gt;&lt;br /&gt;Queuing is one of the base procedures that you may need as a software developer specially if you are working on web.Think as a task that you want to make sure that it will be done, but you don’t want to suspend your current process for it. for instance you want to send an email in a part of a method or task. you don’t want to wait for email response and you want to try sending it for many times, but you never want your methods to wait for it.&lt;br /&gt;If you are developing on EpiServer, you probably know that there is a dynamic data type which is pretty good for implementing a queue.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/link/c3d3fa3681f94eb9b25551e8cd17d3ae.aspx&quot;&gt;Cecilia von Wachenfeldt&lt;/a&gt; has a post in &lt;a href=&quot;/link/90091249c83540669b93a080caabea3e.aspx&quot;&gt;here&lt;/a&gt; where she describes a simple solution for that. However, I don&#39;t like to have both queue and queue item on the same class. From the software architectural view, we have to have a queue class that handles primitive queuing functions (adding to queue, finding unprocessed items, Processing items and deleting them). Then for each type queue, we can just create a corresponding queue-able Item and ask use our queue to handle the object :)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Theory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There has to be a queue, with queue functions. There has to be an enum for the status of the item. Then the queue has to handle everything using each items methods. &lt;br /&gt;&lt;br /&gt;This is the list of classes that we need:&lt;br /&gt;&lt;br /&gt;1- Queue&lt;br /&gt;2- An interface for Queueable Items (IQueueable)&lt;br /&gt;This interface contains properties that the queue will use like ErrorCount, LastError, Status, etc. and basic methods for processing each special type Like Process().&lt;br /&gt;3- Queueable item which inherits from our IQueueable&lt;br /&gt;This item is simply the object that we want to save into DB. It contains our queue properties/methods and also the required data that you need to use, in order to proceed.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Implementation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Lets say that we want to implement an email queue system, so if the network was down or etc, we won&#39;t loose any emails. Our queue and IQueueable are of course the same but for the Queueble Item we have something like this:&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;First, we have to implement our enum to decide if the item is &lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;QueueItemState&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;Queued = 0,&lt;br /&gt;Processed = 1,&lt;br /&gt;Retrying = 2,&lt;br /&gt;Failed = 3&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;Then&lt;/span&gt; we have to write &lt;span class=&quot;type&quot;&gt;our&lt;/span&gt; Interface:&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;IQueueableItem&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;int&lt;/span&gt; ErrorCount { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; LastError { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;DateTime&lt;/span&gt;? QueuedTime { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;DateTime&lt;/span&gt;? CompeletedTime { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;Enums&lt;span class=&quot;type&quot;&gt;QueueItemState&lt;/span&gt; State { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt; AddError(&lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; errorMessage);&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;bool&lt;/span&gt; Process();&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;Identity&lt;/span&gt; Save();&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt; SetToFaild(&lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; errorMessage);&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Then we have to implement our interface and add our additional functionality/properties: &lt;/div&gt;&lt;div&gt;(Pay attention to&amp;nbsp;EPiServerDataStore property that cause Episerver to save this item into DynamicData )&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;[&lt;span class=&quot;type&quot;&gt;EPiServerDataStore&lt;/span&gt;(AutomaticallyRemapStore = &lt;span class=&quot;keyword&quot;&gt;true&lt;/span&gt;, AutomaticallyCreateStore = &lt;span class=&quot;keyword&quot;&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;QueueableEmailItem&lt;/span&gt; : &lt;span class=&quot;type&quot;&gt;IDynamicData&lt;/span&gt;, &lt;span class=&quot;type&quot;&gt;IQueueableItem&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;.... [&lt;span class=&quot;type&quot;&gt;IQueueableItem&lt;/span&gt; properties]&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; EmailSubject { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; EmailBody { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; EmailTo { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;int&lt;/span&gt;? EMailPriority { &lt;span class=&quot;keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;; }&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;bool&lt;/span&gt; Process()&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; priority = EMailPriority.HasValue ? (&lt;span class=&quot;type&quot;&gt;MailPriority&lt;/span&gt;)EMailPriority.Value : System.Net.Mail.&lt;span class=&quot;type&quot;&gt;MailPriority&lt;/span&gt;.Normal;&lt;br /&gt;MailService.Service.Send(EmailSubject, EmailBody, EmailTo, priority, attachedItems);&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;We will need a QueueBase class that handles your queue items. The queue will try to read and execute data that implement IQueueableItem.&amp;nbsp;&lt;/div&gt;&lt;div&gt;There is only one problem, which is reading items from DB with generics, So I just do the process in the queue base and do the other stuff in the inherited classes using polymorphism.&lt;/div&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;QueueBase&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;T&lt;/span&gt; : &lt;span class=&quot;type&quot;&gt;IDynamicData&lt;/span&gt;, &lt;span class=&quot;type&quot;&gt;IQueueableItem&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;void&lt;/span&gt; Proceed()&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; queue = GetQueuedItems();&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (!queue.Any())&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; ;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;foreach&lt;/span&gt; (&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; item &lt;span class=&quot;keyword&quot;&gt;in&lt;/span&gt; queue)&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;comment&quot;&gt;// Exit if the error count is greater or equal to the retry count&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (item.ErrorCount &amp;gt;= RetryCount)&lt;br /&gt;{&lt;br /&gt;item.SetToFaild(&lt;span class=&quot;string&quot;&gt;&quot;RetryCount limit&quot;&lt;/span&gt;);&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;continue&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (item.TryProcess())&lt;br /&gt;{&lt;br /&gt;item.&lt;span class=&quot;type&quot;&gt;State&lt;/span&gt; = Enums.QueueItemState.Processed;&lt;br /&gt;item.Save();&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;continue&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;item.&lt;span class=&quot;type&quot;&gt;State&lt;/span&gt; = Enums.QueueItemState.Retrying;&lt;br /&gt;item.Save();&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;catch&lt;/span&gt; (&lt;span class=&quot;type&quot;&gt;Exception&lt;/span&gt; ex)&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (item.&lt;span class=&quot;type&quot;&gt;State&lt;/span&gt;!= Enums.QueueItemState.Failed)&lt;br /&gt;{&lt;br /&gt;item.&lt;span class=&quot;type&quot;&gt;State&lt;/span&gt; = Enums.QueueItemState.Retrying;&lt;br /&gt;}&lt;br /&gt;item.AddError(ex.message);&lt;br /&gt;item.Save();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Of course you can have a better code, add logs/ return report/ send email to admin if failed, etc. but this is the simplest code that I could come up with :)&lt;/div&gt;&lt;div&gt;Now we will need to inherit from this class for the emailQueue:&lt;/div&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;EmailQueue&lt;/span&gt; : &lt;span class=&quot;type&quot;&gt;QueueBase&lt;/span&gt;&amp;lt;&lt;span class=&quot;type&quot;&gt;QueueableEmailItem&lt;/span&gt;&amp;gt;&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;Identity&lt;/span&gt; AddToQueue(&lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; to, &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; emailSubject, &lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt; body, &lt;span class=&quot;type&quot;&gt;MailPriority&lt;/span&gt; mailPriority = &lt;span class=&quot;type&quot;&gt;MailPriority&lt;/span&gt;.Normal)&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; item = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;QueueableEmailItem&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;EmailTo = to,&lt;br /&gt;EmailSubject = emailSubject,&lt;br /&gt;QueuedTime = &lt;span class=&quot;type&quot;&gt;DateTime&lt;/span&gt;.Now,&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;State&lt;/span&gt; = Enums.QueueItemState.Queued,&lt;br /&gt;ErrorList = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;keyword&quot;&gt;string&lt;/span&gt;&amp;gt;(),&lt;br /&gt;EmailBody = body,&lt;br /&gt;EMailPriority = (&lt;span class=&quot;keyword&quot;&gt;int&lt;/span&gt;)mailPriority&lt;br /&gt;};&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; item.Save();&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;type&quot;&gt;QueueableEmailItem&lt;/span&gt;&amp;gt; GetQueuedItems()&lt;br /&gt;{&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; store = &lt;span class=&quot;keyword&quot;&gt;typeof&lt;/span&gt;(&lt;span class=&quot;type&quot;&gt;QueueableEmailItem&lt;/span&gt;).GetStore();&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; query = (&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;from&lt;/span&gt; item &lt;span class=&quot;keyword&quot;&gt;in&lt;/span&gt; store.Items&amp;lt;&lt;span class=&quot;type&quot;&gt;QueueableEmailItem&lt;/span&gt;&amp;gt;()&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt; item.State == Enums.QueueItemState.Queued || item.&lt;span class=&quot;type&quot;&gt;State&lt;/span&gt; == Enums.QueueItemState.Retrying&lt;br /&gt;&lt;span class=&quot;type&quot;&gt;select&lt;/span&gt; item);&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; query.ToList();&lt;br /&gt;}&lt;br /&gt;}&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/a-simple-queue-for-episerver.html</guid>            <pubDate>Tue, 08 Mar 2016 16:55:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Fake Entire EpiServer</title>            <link>http://pilpag.blogspot.com/2016/03/fake-entire-episerver.html</link>            <description>&lt;span style=&quot;font-size: large;&quot;&gt;Intro&lt;/span&gt;&lt;br /&gt;When doing the integration testing in EpiServer, you will need to mock more than one or two methods or services. Sometimes you need to implement the same ground for different test classes. but it will be very time consuming and at the same time, very hard to write.&lt;br /&gt;Take a simple collaboration service as an example. Your service probably used 3-4 different EpiServer services and 3-4 of your other services (at least:) ), but when you want to test them you find out that you have to mock all used services for your class/service.&lt;br /&gt;&lt;br /&gt;An alternative to this option will be to fake all APIs that you&#39;ve used from EpiServer and then load the faked content on the initial step of your test classes.&lt;br /&gt;&lt;br /&gt;Well, it is like having a huge castle floating in the air. :) time consumable to implement but really easy to expand and change.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;FakeMaker&lt;/span&gt;&lt;br /&gt;So I have an advice for you if you want to fake EpiServer content. Use the FakeMaker by &lt;a href=&quot;https://plus.google.com/102900354628374986520&quot;&gt;David Vujic&lt;/a&gt; to create your pages which will add them automatically to your repository and serviceLocator.&lt;br /&gt;You can more data about it &lt;a href=&quot;http://davidvujic.blogspot.dk/2016/02/fakemaker-is-updated-with-episerver-9-support.html&quot;&gt;here&lt;/a&gt;&amp;nbsp;or download it from &lt;a href=&quot;https://github.com/DavidVujic/EPiServer-FakeMaker/tree/master&quot;&gt;github&lt;/a&gt;&amp;nbsp;or even &lt;a href=&quot;https://www.nuget.org/packages/fakemaker&quot;&gt;nuget&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Need to mention 2 things:&lt;br /&gt;1- Don&#39;t do create a new&amp;nbsp;serviceLocator. Create your pages with FakeMaker and then get your ServiceLocator mock object using this command:&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt; &lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; mockLocator = Mock.Get&amp;lt;IServiceLocator&amp;gt;(ServiceLocator.Current);&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;You will have access to the content repository with your&amp;nbsp;FakeMaker.ContentRepository easily.&lt;br /&gt;&lt;br /&gt;2- If you have EpiServer 8 you cannot use the nuget. just download his code from &lt;a href=&quot;https://github.com/DavidVujic/EPiServer-FakeMaker/tree/epi-8-support&quot;&gt;github&lt;/a&gt;&amp;nbsp;and use it. It is very well written and easy to use&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;My Extention&lt;/span&gt;&lt;br /&gt;When I saw FakeMaker, I understand that it can be pretty usable for many people including me :) &amp;nbsp;so I had a discussion with David and he liked my Ideas. Then I realized that I can contribute in the project so I add other features to my branch. It is not that big deal, but it can be useful for many.&lt;br /&gt;I&#39;ve add 2 options:&lt;br /&gt;1-Supporting&amp;nbsp;EntryContentBase for Commerce system&lt;br /&gt;You can now easily add your products to your fake. It is as easy as creating FakePages. For instance:&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt; &lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; shopRoot = FakePage.Create(&lt;span class=&quot;string&quot;&gt;&quot;ShopRoot&quot;&lt;/span&gt;);&lt;br /&gt; &lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; fakePhone = FakeEntryContent.Create&amp;lt;PhoneProduct&amp;gt;(&lt;span class=&quot;string&quot;&gt;&quot;Iphone 6&quot;&lt;/span&gt;).ChildOf(shopRoot);&lt;br /&gt;_fake.AddToRepository(shopRoot);&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;2-Supporting&amp;nbsp;ContentLoader&lt;br /&gt;In our code, we used ContentLoader in many places while we also used ContentRepository. Of course I wanted to support the ContentLoader when I call AddToRepository :)&lt;br /&gt;You can have access to ContentLoader the same as&amp;nbsp;ContentRepository by FakeMaker.ContentLoader.&lt;br /&gt;Just to mention, it make more sense to create your content in FakeMaker first and then use ContentLoader,&amp;nbsp;ContentRepository, and&amp;nbsp;serviceLocator that it creates for you.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;*You can find my code in &lt;a href=&quot;https://github.com/ashkansiroos/EPiServer-FakeMaker/tree/EntyContentBase-Support&quot;&gt;here&lt;/a&gt;. Just to mention, it is not confirmed by David yet, so it is only on EpiServer 8 that I am using right now and it is not available through nuget pakages, yet.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/fake-entire-episerver.html</guid>            <pubDate>Tue, 08 Mar 2016 15:11:00 GMT</pubDate>           <category>Blog post</category></item><item> <title>Unit Testing in EpiServer using Moq</title>            <link>http://pilpag.blogspot.com/2016/03/unit-testing-in-episerver-using-moq.html</link>            <description>Regardless of what do you think about TDD (Test Driven Development) &amp;nbsp;there are many scenarios that you want to implement an automatic testing in your code. But how do we implement tests in a CMS like EpiServer?&lt;br /&gt;As a basic step, one has to mock some behaviors in EpiServer services like&amp;nbsp;ContentRepository, ContentProviderManager, etrc. To do so, you have to create a mock object from that interface and then use that mock instead of real object. For instance we can do these steps using Moq library:&lt;br /&gt;&lt;br /&gt;1- Create a mock for the service that you want to use&lt;br /&gt;for instance you can create a mock for content loader. This class has been used to load contents from EpiServer, like when you want to load and use a specific page (like setting page) or content.&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; mockContentLoader = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;Mock&lt;/span&gt;&amp;lt;&lt;span class=&quot;type&quot;&gt;IContentLoader&lt;/span&gt;&amp;gt;();&lt;/pre&gt;&lt;/div&gt;&amp;nbsp;2- Mock methods that you need&lt;br /&gt;now you have to tell Moq what you want to return instead of the normal behavior.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;We can ask for a general behavior like returning an object if there was a request for a type. like&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;mockContentLoader.Setup(r =&amp;gt; r.Get&amp;lt;&lt;span class=&quot;type&quot;&gt;StartPage&lt;/span&gt;&amp;gt;(It.IsAny&amp;lt;ContentReference&amp;gt;())).Returns(&lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;StartPage&lt;/span&gt;());&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;this code will return a new StartPage when someone uses ContetnLoader.Get&amp;lt;StartPage&amp;gt; method, with any ContentReference.&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;Or we can mock an specific request like&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;mockContentLoader.Setup(r =&amp;gt; r.Get&amp;lt;StartPage&amp;gt;(myStartPage.ContentLink)).Returns(myStartPage);&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;This code will return your startpage if there is a request with it&#39;s content link. Pretty similar to how you code on EpiServer :)&lt;br /&gt;3-Use the mocked class&lt;br /&gt;To use the class that you mocked, you need an object from it. For instance, when you want to test a class that need your ContentLoader you can do it like this:&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; myServiceToTest = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;MyService&lt;/span&gt;(mockContentLoader.&lt;span class=&quot;type&quot;&gt;Object&lt;/span&gt;);&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;Now you can use your class/service and whenever it wants to use the content loader, it will have the mocked results instead of trying to call DB or etc. :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;*If you want to use the injection in your code, you have to &amp;nbsp;create a new mock for ServiceLocator, or get it if you already have it.&lt;br /&gt;To create a new one use this:&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;            &lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; mockLocator = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;type&quot;&gt;Mock&lt;/span&gt;&amp;lt;&lt;span class=&quot;type&quot;&gt;IServiceLocator&lt;/span&gt;&amp;gt;();&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;To get the existing one use&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;&lt;span class=&quot;type&quot;&gt;var&lt;/span&gt; mockLocator = Mock.Get&amp;lt;IServiceLocator&amp;gt;(ServiceLocator.Current);&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;Now you can easily use the same concept and return your mocked class easily&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;mockLocator.Setup(l =&amp;gt; l.GetInstance&amp;lt;IContentLoader&amp;gt;()).Returns(mockContentLoader.&lt;span class=&quot;type&quot;&gt;Object&lt;/span&gt;);&lt;!--[if IE]&gt;&lt;br /&gt;&lt;br /&gt;&lt;![endif]--&gt;&lt;/pre&gt;&lt;/div&gt;You just need to remember to set the new serviceLocator&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;Code:&lt;br /&gt;&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; color: black; overflow-x: auto; overflow-y: hidden; padding: 0px; text-align: left; word-wrap: normal;&quot;&gt;ServiceLocator.SetLocator(serviceLocator.&lt;span class=&quot;type&quot;&gt;Object&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;&amp;nbsp;To read more about Moq go to &lt;a href=&quot;https://github.com/Moq/moq4/wiki/Quickstart&quot;&gt;this page&lt;/a&gt;&lt;/div&gt;</description>            <guid>http://pilpag.blogspot.com/2016/03/unit-testing-in-episerver-using-moq.html</guid>            <pubDate>Tue, 08 Mar 2016 14:13:00 GMT</pubDate>           <category>Blog post</category></item></channel>
</rss>