tag:blogger.com,1999:blog-91321297706674858342024-03-25T07:06:32.036-07:00Programming is like playing a game (Ashkan Sirous' Blog)It is just a game! Let's have fun!
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-9132129770667485834.post-85903034612891393852019-02-18T08:37:00.003-08:002019-02-18T08:43:57.585-08:00Enabling SCIM using Microsoft.SystemForCrossDomainIdentityManagement - user PATCH request fails<span style="font-size: x-large;">Introduction</span><br />
<br />
SCIM is a protocol to basically sync users and groups (and other resources) meaning that you can have your users on Azure AD, Onelogin, Octa, etc. and keep provisioning the new ones, updating the current ones and deprovision the ones that have left your company to the third party applications.<br />
<br />
A simple documentation of SCIM can be found here:<br />
<a href="http://www.simplecloud.info/">http://www.simplecloud.info/</a><br />
<br />
For .net developers, Microsoft has implemented a nuget package that contains an implementation of the protocol:<br />
<a href="https://www.nuget.org/packages/Microsoft.SystemForCrossDomainIdentityManagement/">https://www.nuget.org/packages/Microsoft.SystemForCrossDomainIdentityManagement/</a><br />
Which is also mentioned in their updated documentation:<br />
<a href="https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/use-scim-to-provision-users-and-groups">https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/use-scim-to-provision-users-and-groups</a><br />
<br />
<span style="font-size: x-large;">The Problems</span><br />
Since Microsoft has the most prominent Identity provider (Active Directory) they have implemented the protocol slightly different than what it was.<br />
1 issue was that they were sending a list of values on a PATCH request for everything including the scaler values. For example lets say someone's displayName has changed. The nuget was designed to receive<br />
<blockquote class="tr_bq">
{"schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"] ,<br />
"Operations":[ {"op":"Replace","path":"displayName","value":<br />
[ {"$ref":null,"value":"User x"}]}]<br />
}}</blockquote>
Instead of<br />
<blockquote class="tr_bq">
{ "schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "Operations": [ {"op":"Replace","path":"displayName","value":" User x"} ]}</blockquote>
Meaning that no one else other than Azure AD could have called your application with PATCH if they have done it right!<br />
<br />
When Azure AD calls our endpoint, it breaks without even reaching the part that is in our hands. The error is pretty simple:<br />
<blockquote class="tr_bq">
<br />
Failed to update User 'xxx@yyy.zzz' in customappsso; Error: StatusCode: BadRequest Message: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details. Web Response: {"Message":"The request is invalid."}. We will retry this operation on the next synchronization attempt.</blockquote>
<span style="font-size: large;">It got wrose!</span><br />
<br />
In December 2018 the problem gor worse, because they have actually corrected their Azure AD's behaviour <a href="https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/application-provisioning-config-problem-scim-compatibility">Advertised here</a> but then didn't fix the nuget package. So your code would just break without you knowing what is wrong and why.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHnBlED9l9IsgeVsKb9zKnl402W9-oP6oPEp_8167wDAwYOCZhL448adQeG3ZJ-e5AD98t_EZ68wcesVmvlITHc5ePUeuKb67lQUNZCxVN74OdFlqohsiwAjK0ODF0i562qGp_ux3FmYc/s1600/2019-02-18+17_28_22-Known+issues+and+resolutions+with+SCIM+2.0+protocol+compliance+of+the+Azure+AD+U.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="318" data-original-width="998" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHnBlED9l9IsgeVsKb9zKnl402W9-oP6oPEp_8167wDAwYOCZhL448adQeG3ZJ-e5AD98t_EZ68wcesVmvlITHc5ePUeuKb67lQUNZCxVN74OdFlqohsiwAjK0ODF0i562qGp_ux3FmYc/s640/2019-02-18+17_28_22-Known+issues+and+resolutions+with+SCIM+2.0+protocol+compliance+of+the+Azure+AD+U.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
I have created a support case for Microsoft and basically wrote everywhere possible, but after a month still there is no update on the package so I've decided to write a small fix for it.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: x-large;">The Solution</span></div>
<div class="separator" style="clear: both; text-align: left;">
The code for the package is not open source and basically there is no right way to do it other than Microsoft change their code and support the correct behaviour, but a simple way to correct their behaviour is to intercept every request using a middleware and change it to the expected format(if it is not already).</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<blockquote class="tr_bq" style="clear: both; text-align: left;">
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">public</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">class</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PatchRequestUpdaterMiddleware</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">OwinMiddleware</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">private</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">const</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">string</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">OperationValueFinderRegex</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"({[\\s\\w\":,.\\[\\]\\\\]*op[\\s\\w\":,.\\[\\]\\\\]*\"value\"\\s*:\\s*)(\"[\\w\\s\\-,.@?!*;\'\\(\\)]+\")"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">//{"op":"x","value":"Andrew1"}</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">public</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">override</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> async </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Task</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Invoke</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">IOwinContext</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> context</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">if</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">context</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Request</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Method</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">ToLower</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">()</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">!=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"patch"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
await </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Next</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Invoke</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">context</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">return</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">var</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> streamReader </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">StreamReader</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">context</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Request</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Body</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">string</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> body </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> streamReader</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">ReadToEnd</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">();</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
body </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Regex</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Replace</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">body</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">OperationValueFinderRegex</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> m </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=></span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> $</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"{m.Groups[1].Value}[{{\"value\":{m.Groups[2].Value}}}]"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">//{"op":"x","value":"Ashkan"} ==>> {"op":"x","value":[{"value":"Ashkan"}]}</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
context</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Request</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Body</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">MemoryStream</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Encoding</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">UTF8</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">GetBytes</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">body</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">));</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
await </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Next</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Invoke</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">context</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">}</span></code></pre>
</blockquote>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
And just add this to the provider that you have created:<br />
<br />
<blockquote class="tr_bq">
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">class</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> myProvider</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">ProviderBase</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">....</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">private</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">OnServiceStartup</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">IAppBuilder</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> appBuilder</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">HttpConfiguration</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> configuration</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">...</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
appBuilder</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Use</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PatchRequestUpdaterMiddleware</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">>();</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">...</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">}</span></code></pre>
</blockquote>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com2tag:blogger.com,1999:blog-9132129770667485834.post-69500001185781401672018-10-23T07:20:00.000-07:002018-10-23T07:24:03.850-07:00Adding Data Lake Analytics to Data Factory<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
For working with Data Lake Analytics in Data Factory, follow the instructions below:</div>
<ol style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; padding-left: 40px;">
<li style="box-sizing: border-box; list-style: inherit;">Add a new Service principal authentication if you don't have one<ul style="box-sizing: border-box; padding: 0px 0px 0px 20px;">
<li style="box-sizing: border-box; list-style: inherit;">In portal go to Active Directory >App registrations>+ New application registration> Provide a name and URL for the application</li>
</ul>
</li>
</ol>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqMEgR6lJIzcD1kaMDTpiI1jCj_zSQPbTpykJDnrKG_hX5gno3V2CcoCjmeyD7BDm9wMfmmetxWE3lFE_Gdv4Dy5Dtu40suwhVS4hTVgPqSd5iFU4rhoCIrqiCqBiIWXwm_AVNUhyphenhypheng5pA/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="481" data-original-width="452" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqMEgR6lJIzcD1kaMDTpiI1jCj_zSQPbTpykJDnrKG_hX5gno3V2CcoCjmeyD7BDm9wMfmmetxWE3lFE_Gdv4Dy5Dtu40suwhVS4hTVgPqSd5iFU4rhoCIrqiCqBiIWXwm_AVNUhyphenhypheng5pA/s320/1.png" width="300" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIZbJWn5CCKgc9oHohiFCx40qcD0Y3GzQOVyQHgNejxcqKqV3au_vzIU-kEtrSe_Th_5lTjV9mKkf6aNkISaUvFskfg3ISUV5t70ev8M6BHYmqVkgDi6Ar3oRfNO9EyXiTdrIRNoypD5g/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="117" data-original-width="577" height="64" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIZbJWn5CCKgc9oHohiFCx40qcD0Y3GzQOVyQHgNejxcqKqV3au_vzIU-kEtrSe_Th_5lTjV9mKkf6aNkISaUvFskfg3ISUV5t70ev8M6BHYmqVkgDi6Ar3oRfNO9EyXiTdrIRNoypD5g/s320/2.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuJf25-fJEWf8unl6GvMJ5G1iCvVVPZow8K07ldQ2KvhAJaAj9tnyX9cFzlk4eD0Rka8JG-V_Tla-1yn-aFgnBu_n362DYaAaHOlnIcLXDOjp3B_FA6mRKSk-mR29atE8OAMcqTQr08tU/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="423" data-original-width="304" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuJf25-fJEWf8unl6GvMJ5G1iCvVVPZow8K07ldQ2KvhAJaAj9tnyX9cFzlk4eD0Rka8JG-V_Tla-1yn-aFgnBu_n362DYaAaHOlnIcLXDOjp3B_FA6mRKSk-mR29atE8OAMcqTQr08tU/s320/3.png" width="229" /></a></div>
<br />
<br /></div>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
2- Take the Pricipal key and Id for the user:<br />
<strong style="box-sizing: border-box;">Id:</strong> Active Directory>App registrations>Application ID<br />
<strong style="box-sizing: border-box;">Key:</strong> Active Directory>App registrations>Settings>Keys--> add new one</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6wXnJlK4COZPI_ChG7K428U1pODqP4eIUX9tRSVmVW9tjbanxDH13p9mPP77LPccQAdl1erzoVCgWxVDHBBdgH0eNntTWFnO4ee36wA3bIMZ1vvK74XUhcBf84BZMneQYKLH08zogwMU/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="339" data-original-width="402" height="269" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6wXnJlK4COZPI_ChG7K428U1pODqP4eIUX9tRSVmVW9tjbanxDH13p9mPP77LPccQAdl1erzoVCgWxVDHBBdgH0eNntTWFnO4ee36wA3bIMZ1vvK74XUhcBf84BZMneQYKLH08zogwMU/s320/1.jpg" width="320" /></a></div>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
3- Add the key to the Key vault and take the name for it<br />
Go to Key vault account related to the resource group that you are in and add a secret to it</div>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
4- Give permission to both the Data Lake Analytics and the Data Lake Store it uses.<br />
Grant service principal permission to your Azure Data Lake Anatlyics using the Add User Wizard</div>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
Giving access to <strong style="box-sizing: border-box;">Data Lake Analytics</strong><br />
In the Azure portal, go to your Data Lake Analytics account.</div>
<ul style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; padding: 0px 0px 0px 20px;">
<li style="box-sizing: border-box; list-style: inherit;">On the left, under Getting Started, click Add User Wizard.</li>
<li style="box-sizing: border-box; list-style: inherit;">Select a role ( we can use contributer), and then click Select.</li>
<li style="box-sizing: border-box; list-style: inherit;">Paste the principal Id from the step 2 in the search field. it will find the principal (user) name</li>
<li style="box-sizing: border-box; list-style: inherit;">Select the access control lists (ACLs) for the U-SQL databases. When you're satisfied with your choices, click Select.</li>
<li style="box-sizing: border-box; list-style: inherit;">Select the ACLs for files. For the default store, don't change the ACLs for the root folder "/" and for the /system folder. Click Select.</li>
<li style="box-sizing: border-box; list-style: inherit;">Review all your selected changes, and then click Run.</li>
<li style="box-sizing: border-box; list-style: inherit;">When the wizard is finished, click Done.</li>
</ul>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
Giving access to <b> Data Lake Store</b><br />
In the Azure portal, go to your Data Lake Store account.</div>
<ul style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; padding: 0px 0px 0px 20px;">
<li style="box-sizing: border-box; list-style: inherit;">Access control (IAM)</li>
<li style="box-sizing: border-box; list-style: inherit;">Click add</li>
<li style="box-sizing: border-box; list-style: inherit;">Select the role (CONTRIBUTOR)</li>
<li style="box-sizing: border-box; list-style: inherit;">Paste Pricipal ID in the search field to find the principal (user)</li>
</ul>
<div style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
5- Add a Linked service in Data Factory<br />
Go to the Data Factory> Connections> + New</div>
<ul style="background-color: white; box-sizing: border-box; color: rgba(0, 0, 0, 0.9); font-family: "Segoe UI VSS (Regular)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Ubuntu, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; margin-bottom: 0px; padding: 0px 0px 0px 20px;">
<li style="box-sizing: border-box; list-style: inherit;">From <strong style="box-sizing: border-box;">Compute tab</strong> select >Azure Data Lake Analytics</li>
<li style="box-sizing: border-box; list-style: inherit;">Give it a good name and feel the values for tenant and service</li>
<li style="box-sizing: border-box; list-style: inherit;">Set the principal Id from step 2</li>
<li style="box-sizing: border-box; list-style: inherit;">select Key Vault option and feel the secret name</li>
<li style="box-sizing: border-box; list-style: inherit;">click on test connection to see that Azure data factory can get connected to the Data Lake Analytics</li>
</ul>
<div>
<span style="color: rgba(0, 0, 0, 0.901960784313726);"><span style="font-size: 14px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihluCs1lWZubSgOHK6W_x74aUFbev34uweZHpTUx7tISGH3HAlEmoN08ofCb40hT0CMkWBIMbFy8Ewf0BIFK83XXIDf9l7wMKYuRFiKmNb_BYrJg3wKNGY76a8i5lKihZQN9I0rXljMhE/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="459" data-original-width="625" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihluCs1lWZubSgOHK6W_x74aUFbev34uweZHpTUx7tISGH3HAlEmoN08ofCb40hT0CMkWBIMbFy8Ewf0BIFK83XXIDf9l7wMKYuRFiKmNb_BYrJg3wKNGY76a8i5lKihZQN9I0rXljMhE/s320/4.png" width="320" /></a></div>
<div>
<span style="color: rgba(0, 0, 0, 0.901960784313726);"><span style="font-size: 14px;"><br /></span></span></div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com2tag:blogger.com,1999:blog-9132129770667485834.post-43331861047737541672018-10-23T07:15:00.000-07:002018-10-23T07:15:39.391-07:00Accessing resources in Azure<h2>
Introduction</h2>
<br />
The old way of accessing resources like blob storage was connection string. Later services have been added to Azure like Key Vault in order let people store keys, secrets and certificates in order to let developers do their job while protecting the production environments from the rouge ones :).<br />
<br />
That being said, there is new ways to give access to platforms so they can access each other. For example in Azure Data Lake Analytics, you might want to access Azure Data Lake Store, Blob storage and Data Factory and to do that you need to give it access for each of them.<br />
<br />
<h2>
Where to find values that we need?</h2>
<h3>
DataFactory</h3>
For the data factory, if we were about to follow the same lead, meaning that we needed a service principal Id and key that can be created using active directory, but it turns out that we don't need to as Azure have a newer concept called "managed identity" which has already been created when we have created the Data factory using Portal. We just need to make sure that the data factory identity have access to the DataLakeStor.<br />
So what we need to set in the parameters is only the subscription and resource group in the release pipeline.<br />
<br />
* We could also use managed identities to connect to Blob storage on Azure.<br />
<br />
You can read more about managed identities for Azure here<br />
<a href="https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview">https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview</a><br />
<br />
<h3>
Data Lake Analytics</h3>
In any case if we need to have a service principal (like for the Data lake analytics), we can just create an app in active directory and make sure that app have access to the resources we need. Then we can read the Id and key as below:<br />
<br />
<b>Id: Active Directory>App registrations>Application ID</b><br />
<b>Key: Active Directory>App registrations>Settings>Keys--> add new one</b><br />
<br />
read more about how to do it in here:<br />
<a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal</a>Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com1tag:blogger.com,1999:blog-9132129770667485834.post-45279072208790042952018-04-05T01:20:00.001-07:002018-04-05T01:20:30.492-07:00Deleting old files on Azure web app (app service)<h2>
Introduction</h2>
<div>
It is going to be a short post :)</div>
<div>
In Azure we usually use application insights or something similar to keep track of your logs. If for some reason you like to keep everything also in log files, for example in App_data you will have a lot of files in no time. Usually the size is not that much matter since you have 100 GB on your disk, but it is also annoying that you have to look into thousands of files (usually 1 file per day per scaled instance).</div>
<div>
<br /></div>
<h3>
Where are my files</h3>
<div>
You probably know it already since you are trying to delete them :) but for people who have searched for something else, lets say your app service is in test.azurewebsites.net/ you can access the disk using test<span style="background-color: yellow;">.scm</span>.azurewebsites.net/ </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Then you can click on "Debug console" from top menu and click on CMD to see all folders and files. To visit the place that your files have been hosted just go to <b>Site> wwwroot</b></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nFQxdmmKLlMKPTnnY9gm5-n0-7LtFWOXXNX2Wp-wjS5T1jc2mmRI1yFlbr-mEAL7ZYADtY1Jo9ZdKQpQ6mAYnoJVloQHaQRiYtbfWEtAyVeGxg1V5IywG3pO5J6GMOGcTasC59H6Gvg/s1600/2018-04-05+10_14_56-Diagnostic+Console.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="692" data-original-width="1085" height="408" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nFQxdmmKLlMKPTnnY9gm5-n0-7LtFWOXXNX2Wp-wjS5T1jc2mmRI1yFlbr-mEAL7ZYADtY1Jo9ZdKQpQ6mAYnoJVloQHaQRiYtbfWEtAyVeGxg1V5IywG3pO5J6GMOGcTasC59H6Gvg/s640/2018-04-05+10_14_56-Diagnostic+Console.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQYJtvq_prGnCgoVDwAaJGRhQd7KInaAD4ajSMOowSbUjea_q4OQFx2Mbd6SBF8DyrF8lAivqZUBygIkj0Lis-vFWYlIJTm7Gsjpdn0MSUViDHheyoel4hKILFsmHFVMV8n_zolpcxZ9I/s1600/2018-04-05+10_15_19-Diagnostic+Console.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="686" data-original-width="1216" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQYJtvq_prGnCgoVDwAaJGRhQd7KInaAD4ajSMOowSbUjea_q4OQFx2Mbd6SBF8DyrF8lAivqZUBygIkj0Lis-vFWYlIJTm7Gsjpdn0MSUViDHheyoel4hKILFsmHFVMV8n_zolpcxZ9I/s640/2018-04-05+10_15_19-Diagnostic+Console.png" width="640" /></a></div>
<div>
<br /></div>
<h3>
The simple solution</h3>
<div>
One simple solution is to delete the old files that you know you are not going to need. For example you might have a policy to say you don't care about what has happen more than 30 days ago. </div>
<div>
<br /></div>
<h3>
How?</h3>
<div>
Well, basically it is Windows so you can simply use command prompt's commands to do stuff. </div>
<div>
<div>
Use this command to <span style="background-color: yellow;">see</span> the list of the files older than 30 days</div>
<blockquote class="tr_bq">
forfiles -s -m *.* -d -30 -c "cmd /c <span style="background-color: yellow;">eco </span>@file"</blockquote>
<div>
<br /></div>
<div>
If you were happy with the results, change <span style="background-color: yellow;">eco </span>to <span style="background-color: yellow;">del </span>to delete those files:</div>
<blockquote class="tr_bq">
forfiles -s -m *.* -d -30 -c "cmd /c <span style="background-color: yellow;">del </span>@file"</blockquote>
</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVvj9IRfZNsul_T4J6ySei522vuKzEhSl4k3UCdyhII-oC3xUsbJFqLKd3FcS9THQinUCdHC-NTBgjp1mTmrkdHZgV3DY6vV2ig_57IrgaxGkH-ovmAfm3kckPk7o2Kpg9m0ncYEt66n4/s1600/2018-04-05+10_15_43-Diagnostic+Console.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="756" data-original-width="1403" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVvj9IRfZNsul_T4J6ySei522vuKzEhSl4k3UCdyhII-oC3xUsbJFqLKd3FcS9THQinUCdHC-NTBgjp1mTmrkdHZgV3DY6vV2ig_57IrgaxGkH-ovmAfm3kckPk7o2Kpg9m0ncYEt66n4/s640/2018-04-05+10_15_43-Diagnostic+Console.png" width="640" /></a></div>
<br /></div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com22tag:blogger.com,1999:blog-9132129770667485834.post-32377552700825796832017-11-22T08:33:00.000-08:002017-11-23T10:17:56.483-08:00Umbraco for beginners: How to see versions of a property on a page (back in history)<span style="font-size: x-large;">Introduction</span><br />
All CMS systems log data versions and the person who has changed them. Umbraco is of course is not an exception regarding this matter :)<br />
But how can we check and see how has done the change?<br />
<br />
There are probably some add-ins for that, but what if you don't want to let other people see old data? What if you don't have time, or not allowed to install a package on the production server?<br />
Right?<br />
<br />
It is pretty simple :). you just need to query on the Database<br />
<br />
<br />
<br />
<span style="font-size: large;">Wrong text back in history</span><br />
<br />
Lets say your client sends you a bug report and when you check it you see that a text field is not correct. For the sake of example, lets say you have several email subjects in your CMS and you have a bug report saying someone has received "Subject 2" instead of "Subject 1". What will you do?<br />
<br />
Of course first action is to check CMS and then checking code, but what if everything is right? Isn't it possible that for a period of time an editor changed it to the wrong value and after a while corrected it? How would you check that?<br />
<br />
A simple query like this<br />
<br />
<pre class="lang-sql prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">SELECT</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">TOP</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">1000</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
pt</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Alias </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">pt</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Name</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cpd</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dataNvarchar</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cd</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">updateDate</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> u</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">username
</span><span class="com" style="border: 0px; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">--,pt.*, cpd.*, cd.*</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">FROM</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dbo</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">cmsPropertyData</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cpd
</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">inner</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">join</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dbo</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">cmsDocument</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cd </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">on</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cpd</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">versionId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cd</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">versionId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">inner</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">join</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dbo</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">cmsPropertyType</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> pt </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">on</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> pt</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">id </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cpd</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">propertytypeid
</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">inner</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">join</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dbo</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">umbracoUser</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> u </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">on</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> u</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">id </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> cd</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">documentuser
</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">where</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> datanvarchar </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">like</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">'%Subject 2%'</span></code></pre>
With this query you will find all property names in the history that "%Subject 2%" has been assign to them with date and the one who is responsible. Also you can filter on any other fileds like nodeId (page id) and also you can check other data types (dataInt, dataDecimal, dataDate, dataNvarchar, dataNtext)<br />
<br />
<br />
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com0tag:blogger.com,1999:blog-9132129770667485834.post-48681690973746610102017-11-10T07:04:00.001-08:002017-11-10T07:04:41.359-08:00Caching partials in Umbraco 7.7Umbraco has a nice way of implementing output caching in the views. It is exactly the same ass calling a partial, but you can say how long you want that partial to be cached and how should Umbraco understand if it should return cached data or build it again.<br />
You could find the documentation <a href="https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views">in here</a>.<br />
<br />
<h2>
<span style="font-size: large;"><b>Quick examples:</b></span></h2>
<div>
one can use CachedPartial without specifying anything else which means that you want the same partial showing every time no matter where it is.</div>
<div>
For instance if you want to show footer or menu of your site, it is pretty easy to have them in a partial and then just call Html.CachedPartial("_menu",....) on the master page/ layout page.</div>
<div>
<br /></div>
<div>
<div>
<span class="pln" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;"> </span><span class="lit" style="background-color: #eff0f1; border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; 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;">@Html</span><span class="pun" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">.</span><span class="typ" style="background-color: #eff0f1; border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; 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;">CachedPartial</span><span class="pun" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">(</span><span class="str" style="background-color: #eff0f1; border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; 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;">"_partial"</span><span class="pun" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">,</span><span class="pln" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;"> </span><span class="typ" style="background-color: #eff0f1; border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; 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;">Model</span><span class="pun" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">,</span><span class="pln" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;"> chachtime</span><span class="pun" style="background-color: #eff0f1; border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">)</span><span class="com" style="background-color: #eff0f1; border: 0px; color: #858c93; font-family: inherit; font-size: inherit; 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;">//caching for everypage</span></div>
On the other hand you might want to show different views for each member. An example could be a module to show username or other user specified data.<br />
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">@Html</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">CachedPartial</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"_partial"</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Model</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> chachtime</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">cacheByMember</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">true</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="com" style="border: 0px; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">//caching based on the member</span></code></pre>
Then there are times that you want to have your data showing differently based on different pages that they are on. For instance you want to write meta data of each page, but you don't care which user is that.<br />
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">@Html</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">CachedPartial</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"_partial"</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Model</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> chachtime</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">cacheByPage</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">true</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="com" style="border: 0px; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">//caching based on pages</span></code></pre>
We can also do combination of page and members. </div>
<div>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">@Html</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">CachedPartial</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"_partial"</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Model</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> chachtime</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">cacheByPage</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">true,</span></code>cacheByMember<span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">:</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; 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;">true</span>)<span class="com" style="border: 0px; color: #858c93; font-family: inherit; font-size: inherit; 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;">//caching based on pages and members</span></pre>
<pre class="lang-cs prettyprint prettyprinted" style="border: 0px; 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;"><span class="com" style="border: 0px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></pre>
But what if you want to cache your partial based on something else? What if you have some querystrings that contains some items that you want to differentiate based on that?</div>
<div>
Lets say you have a small advertising site and for some reasons, you have your product Ids in the querystring. If you cache the page by page, it will just show everyone the first product that someone has browsed for the cache period which is not good.</div>
<div>
Cachebymemebr is not also usable because you don't care if the person is logged in or different. You just care about the querystring that you have (productIds)</div>
<div>
The way to do it is using <span style="background-color: #eff0f1; color: #303336; font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; white-space: inherit;">contextualKeyBuilder </span>like below: </div>
<div>
<br />
<pre class="lang-cs prettyprint prettyprinted" style="border: 0px; 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;"><span class="com" style="border: 0px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><code><pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; white-space: inherit; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">@Html</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">CachedPartial</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"_partial"</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Model</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> chachtime</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; white-space: inherit; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">contextualKeyBuilder</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">:(</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">o</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> dictionary</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=></span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; white-space: inherit; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">CurrentPage</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">ToString</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">()</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">+</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Request</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">QueryString</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">ToString</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">())</span></code></pre>
</code>You can specify the key based on your scenario or even pageview data.</span></pre>
</div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com14tag:blogger.com,1999:blog-9132129770667485834.post-1226580510005099802017-10-20T04:39:00.001-07:002017-10-22T02:48:42.019-07:00Beginners Guide: Output caching in EPiServer<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtD_SB4ggqKG6DHd_vDk_CkanczKJnoDv7IQPhKrZ88MVQXjUXidfouKl-9NtfPsdY1TbszPqorLl-_4h604xUwhI7reY7Bqvt3hzPyPOW3zxekHF-6DD1Rj9yo5v9tzroOK-b97ufz8g/s1600/download.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="168" data-original-width="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtD_SB4ggqKG6DHd_vDk_CkanczKJnoDv7IQPhKrZ88MVQXjUXidfouKl-9NtfPsdY1TbszPqorLl-_4h604xUwhI7reY7Bqvt3hzPyPOW3zxekHF-6DD1Rj9yo5v9tzroOK-b97ufz8g/s1600/download.jpg" /></a></div>
<h2>
<span style="font-size: large;"><b><br /></b></span></h2>
<h2>
<span style="font-size: large;"><b><br /></b></span></h2>
<h2>
<span style="font-size: large;"><b>Introduction</b> </span></h2>
<br />
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?<br />
<br />
<h2>
<span style="font-size: large;">What is Output caching?</span></h2>
<div>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;">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. </span></div>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;"><span style="font-size: large;"><b><br /></b></span></span></div>
<h2 style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;"><span style="font-size: large;">Why using output caching?</span></span></h2>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;">Output Caching has huge advantages, such as:</span></div>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;">*Reduces the load on the server because there is no need to generate the results again</span></div>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;">* Reduces the load on DB (same reason)</span></div>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;">* Faster response</span></div>
<div style="font-family: "Segoe UI", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-stretch: normal; font-weight: normal; line-height: 1.167; margin-top: 0px;">
<span style="background-color: white; color: #212121; font-family: "open sans" , sans-serif;"><span style="font-size: large;"><br /></span></span></div>
<h2 style="font-stretch: normal; line-height: 1.167; margin-top: 0px;">
<span style="color: #212121; font-family: "open sans" , sans-serif; font-size: large;"><span style="background-color: white;">How it is done on MVC?</span></span></h2>
</div>
<div>
<div style="font-stretch: normal; line-height: 1.167; margin-top: 0px;">
<span style="font-size: small;"><span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif;">OutputCacheAttribute class has been implemented in </span></span>System.Web.Mvc class and can easily being used simply by decorating the Controller with [<span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif;">OutputCache</span>]<span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif;">. There are different variations for using it, which I am not going to discuss now, but you can read more in <a href="https://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute(v=vs.118).aspx">here</a>.</span></div>
<div style="font-stretch: normal; line-height: 1.167; margin-top: 0px;">
<span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif;"><br /></span></div>
<h2 style="font-stretch: normal; line-height: 1.167; margin-top: 0px;">
<span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: large;">What is the problem? Lets use it on EpiServer.</span></h2>
</div>
<span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif;">Although </span>[<span style="font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif;">OutputCache</span>] attribute works fine for MVC applications, there are some functionalities that are specific to CMS systems. Let me elaborate more with an example:<br />
- 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.<br />
A second later, another person requests the same exact page. As you've guessed the MVC will receive the request and since it has it on its cache, it will respond with the same exact results.<br />
- 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't know about the change and will still return the same response. This also happens for the next people whom request the same page.<br />
<br />
So to summarize we have 2 big problem:<br />
1- content should not be cached for the editors<br />
2- After publishing a page the old cache should be invalidate and the whole process should go through<br />
<br />
<br />
<h2>
<span style="font-size: large;">How to fix it?</span></h2>
<div>
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 ContentOutputCacheAttribute that will handle those for you :)</div>
<div>
<br /></div>
<div>
Simply add ContentOutputCache on top of your action </div>
<div>
<br /></div>
<div>
<pre style="background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"> public class MyPageController : PageController<PageType>
{
[ContentOutputCache(Duration = 3600, VaryByCustom = "*")]
public ActionResult Index(StartPage currentPage)
{
...
}
}</code></pre>
</div>
<div>
<br /></div>
<div>
Handle your GetVaryByCustomString in your Global.asax and you are good to go</div>
<div>
<br /></div>
<div>
<pre style="background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;">public class EPiServerApplication : EPiServer.Global
{
public override string GetVaryByCustomString(HttpContext context, string custom)
{
....
}
}</code></pre>
</div>
<div>
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.</div>
<div>
<br /></div>
<div>
<pre style="background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"> public override string GetVaryByCustomString(HttpContext context, string custom)
{
return context.Request.Url.AbsoluteUri;
}</code></pre>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: red; font-size: x-large;"><b style="background-color: yellow;">****Very Important!!!!</b></span></div>
<br />
<br />
ContentOutputCache will not work, unless you have the httpCacheExpiration in your web.config.<br />
<div>
Simply go to your webconfig></div>
<div>
configuration>episerver>applicationSettings and make sure that it has properties for httpCacheability and httpCacheExpiration.<br />
<br />
It should be something like this:</div>
<div>
<br /></div>
<div>
<pre style="background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><configuration>
...
<episerver>
<applicationSettings httpCacheability="Public" httpCacheExpiration="0:10:00" .... />
</episerver>
....
</configuration></code></pre>
</div>
<div>
<br />
<div>
<br /></div>
<div>
<br /></div>
</div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com18tag:blogger.com,1999:blog-9132129770667485834.post-80858628278701940142017-09-11T12:22:00.003-07:002017-09-11T12:25:06.815-07:00Clean code trap for Entity framework<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifuXd_NXj9hCcEuqShuQBy42epP5W0ynPx29DUMEgwvDvdOL8_fl2Yo4Z9cmT7NXnezB6feQfVKMhrj1iiAGMHtuoHPCYr7P9flsX6KyMPUnjLAlFogi2KWy4WFHodC6hfyoA5-0IC6Jw/s1600/trap.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifuXd_NXj9hCcEuqShuQBy42epP5W0ynPx29DUMEgwvDvdOL8_fl2Yo4Z9cmT7NXnezB6feQfVKMhrj1iiAGMHtuoHPCYr7P9flsX6KyMPUnjLAlFogi2KWy4WFHodC6hfyoA5-0IC6Jw/s320/trap.jpg" width="320" /></a></div>
<br />
<br />
<br />
When writing a code, it is pretty normal to extract a part of your code to a new method in order to have a cleaner and human readable code.<br />
Take this example:<br />
<br />
PostTable (1) ===> (n) Votes<br />
<br />
<br />
You have a post table that contains a lot of columns and you also like to retrieve total number of votes for that post.<br />
A simple query would be:<br />
<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">db</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">posts.where(....)</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Select</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(Convert</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span></code></pre>
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><pre style="border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;">public static Dto Convert(Post p)
{
return new Dto{
Title= p.Title,
...
Other fields
....
VoteCount= p.Votes.Count
}
}</code></pre>
</pre>
<br />
Simple. Right?<br />
But then your query will be translated as a query to take Post object and 1 query for each of the posts to read its votes and it is not the worst part! it will fetch all the votes instead of counting them:<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">exec</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> sp_executesql N</span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">'SELECT
[Extent1].[Id] AS [Id],
[Extent1].[PostId] AS [PostId],
FROM [dbo].[Votes] AS [Extent1]
WHERE [Extent1].[PostId] = @EntityKeyValue1'</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">N</span><span class="str" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">'@EntityKeyValue1 int'</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">@EntityKeyValue1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">6</span></code></pre>
<br />
Then you might say, you can Include your vote table in your query. Like this:<br />
<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> db</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">posts
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Include</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">p</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=></span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">p</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Votes</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span></code>.where(....)<span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; 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;">Select</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">(Convert</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; 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;">)</span></pre>
But then it will be translated into a big join<br />
<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">SELECT
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Title</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Title</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">C1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">C1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Pid</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Pid</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PostId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PostId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
FROM </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> SELECT
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Title</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Title</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent2</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent2</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PostId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PostId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">],</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
CASE WHEN </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">([</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent2</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> IS NULL</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> THEN CAST</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">NULL AS </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">int</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> ELSE </span><span class="lit" style="border: 0px; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">1</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">END</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">C1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
FROM </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dbo</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Posts</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
LEFT OUTER JOIN </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">dbo</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Votes</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent2</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> ON </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Extent2</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PostId</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> AS </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
ORDER BY </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Id</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> ASC</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Project1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">].[</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">C1</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> ASC</span></code></pre>
So what is wrong?!!<br />
<br />
<br />
As you may already have guessed it. Do not put the select into a separated method. call your query simply like this:<br />
<br />
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", 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;"><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">db</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">posts.Where(....)</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Select</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">p</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=></span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">PostlDto</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Title</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> p</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Title</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">VoteCount</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> p</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Votes</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Count, ....</span><span class="pun" style="border: 0px; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">})</span></code></pre>
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com1tag:blogger.com,1999:blog-9132129770667485834.post-54034366899220385052017-08-17T06:42:00.000-07:002017-08-17T06:42:22.720-07:00Forcing Umbraco install your DB again<h2>
Introduction</h2>
<br />
When you install Umbraco nuget package for the first time, it will show you a pretty installation windows and then tries to install the DB for you. What if you want to do the same when publishing your code somewhere else? What is you don't care about your site content and just want the views/ templates like for your test/staging server?<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3zvbCTM_1aC2CsCNiSgPVfkB92Y2Rd__6RoIbwpunD7QVzwTWm48tUziRmkPG-X1lXbh7REq_KGMxXaVXis3UL0bnOjks8K4d0a5Wo0z6cyTFLSHNv8AOtezUsu3Tb3irNppRFERdAh8/s1600/umbracoInstall.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1285" data-original-width="1600" height="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3zvbCTM_1aC2CsCNiSgPVfkB92Y2Rd__6RoIbwpunD7QVzwTWm48tUziRmkPG-X1lXbh7REq_KGMxXaVXis3UL0bnOjks8K4d0a5Wo0z6cyTFLSHNv8AOtezUsu3Tb3irNppRFERdAh8/s320/umbracoInstall.jpg" width="320" /></a></div>
<br />
<br />
<h2>
Umbraco settings</h2>
<br />
In the web config> <appSettings> of your project there is a setting that tells Umbraco which version are you on.<br />
<blockquote class="tr_bq">
<span style="background-color: yellow;"><add key="umbracoConfigurationStatus" value="7.6.5" /></span></blockquote>
<br />
If you <span style="background-color: yellow;">remove it from the config</span>, Umbraco has no other way than installing the DataBase again, and you will see the installation page when you try to access to the page. But wait! why doesn't it do anything?<br />
If you take a look at the developer tools of your browser you will see that one of the requests has been failed<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpq3ZLvFlVp1YxICvk4SH1xpJrqxtDY_KMwphATZFzLBvZGtRPnKvH1E0aYlMI3AMe1c21PAtVZ1jNbVHtrEfEQkSahq7jNRMhw-9z_c2bEnMkbaIfOXpyjaGR09Q3LSg4rA236RP9kjM/s1600/setupError.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="471" data-original-width="1321" height="114" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpq3ZLvFlVp1YxICvk4SH1xpJrqxtDY_KMwphATZFzLBvZGtRPnKvH1E0aYlMI3AMe1c21PAtVZ1jNbVHtrEfEQkSahq7jNRMhw-9z_c2bEnMkbaIfOXpyjaGR09Q3LSg4rA236RP9kjM/s320/setupError.jpg" width="320" /></a></div>
<br />
<br />
<br />
This is the Error:<br />
<br />
<blockquote class="tr_bq">
{"Message":"An error has occurred.","ExceptionMessage":"Invalid object name 'umbracoUser'.","ExceptionType":"System.Data.SqlClient.SqlException","StackTrace":" at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n at ....</blockquote>
So what is wrong?<br />
<br />
Since we have set our connection string before, Umbraco thinks that there is a DB somewhere that has your User structure and tries to load your user. :)<br />
<span style="background-color: yellow;">Simply remove the Connection string and you will be fine </span><br />
<br />
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com2tag:blogger.com,1999:blog-9132129770667485834.post-8546008196972408032017-03-03T07:04:00.005-08:002017-03-03T07:15:52.619-08:00Reactjs.net 3.0 and the error "Object doesn't support property or method 'assign' on server!" on ASP.net MVC (windows server 2012 r2)<h2>
Reactjs.net 3.0 and the error "Object doesn't support property or method 'assign' on server!"on ASP.net MVC </h2>
<span style="font-size: large;"><b><br /></b></span>
<span style="font-size: large;"><b><br /></b></span>
<span style="font-size: large;"><b>* If you are too lazy to read the whole text just read the solution</b></span><br />
<br />
<h3>
<br />Error</h3>
We are using Reactjs.net to generate some of our front-end code and it is a very good tool. On my new project, I've installed Reactjs.net v 3.0.1 on my local system and everything was fine until the time that I had to publish to test server which was Windows server 2012 r2 were I get the error<br />
<br />
<pre class="brush: csharp">
Failed to render mycomponent
Reason: Object doesn't support property or method 'assign'</pre>
<div style="border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; padding: 0px;">
<br /></div>
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; margin-bottom: 1em; padding: 0px;">
<strong style="border: 0px; margin: 0px; padding: 0px;">Stacktrace</strong></div>
<pre class="brush: csharp">
TypeError: Object doesn't support property or method 'assign'
at o (Unknown script code:1:14914)
at w._constructComponentWithoutOwner (Unknown script code:9:12601)
at w._constructComponent (Unknown script code:9:12465)
at w.mountComponent (Unknown script code:9:11635)
at mountComponent (Unknown script code:1:13246)
at Mixin.mountChildren (Unknown script code:10:9072)
at h.Mixin._createContentMarkup (Unknown script code:9:25488)
at h.Mixin.mountComponent (Unknown script code:9:24086)
at mountComponent (Unknown script code:1:13246)
at Mixin.mountChildren (Unknown script code:10:9072)
</pre>
<h3>
<br /></h3>
<h3>
Digging in</h3>
<div>
So I started to dig in. I've published my code to my local IIS and test it with the same connection string and everything and it was fine, but when I copied the same files to the server I had the error.<br />
<div>
With more investigation I found this post <a href="https://github.com/reactjs/React.NET/issues/220" target="_blank">here</a> on issues</div>
<div>
<br /></div>
<div>
<div style="background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; margin-bottom: 16px;">
By default ReactJS.NET will try to use V8, and fall back to the MSIE JS engine if V8 does not initialise correctly for some reason. There's a few machine-dependent bits:</div>
<ul style="background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;">
<li style="box-sizing: border-box; margin-left: 0px;">V8 depends on the Visual C++ 2013 runtime (<code style="background-color: rgba(27, 31, 35, 0.0470588); border-radius: 3px; box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 11.9px; margin: 0px; padding: 0.2em 0px;">msvcp120.dll</code> and <code style="background-color: rgba(27, 31, 35, 0.0470588); border-radius: 3px; box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 11.9px; margin: 0px; padding: 0.2em 0px;">msvcr120.dll</code>)</li>
<li style="box-sizing: border-box; margin-left: 0px; margin-top: 0.25em;">MSIE depends on the version of Internet Explorer installed</li>
</ul>
<div style="background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
You can disable the MSIE fallback by doing <code style="background-color: rgba(27, 31, 35, 0.0470588); border-radius: 3px; box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 11.9px; margin: 0px; padding: 0.2em 0px;">.SetAllowMsieEngine(false)</code> in your config.</div>
<div style="background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;">
<br /></div>
<br />
So as I've expected there is a strong relation between the error and the environment itself! Therefore, I've installed the latest version on Visual C++ 2013 runtime and checked Internet explorer version. but nothing worked.<br />
<br />
<div style="box-sizing: border-box;">
Then I've found<span style="color: #24292e; font-family: , "blinkmacsystemfont" , "segoe ui" , "helvetica" , "arial" , sans-serif , "apple color emoji" , "segoe ui emoji" , "segoe ui symbol";"><span style="background-color: white; font-size: 14px;"> </span></span><a href="https://github.com/Taritsyn/JavaScriptEngineSwitcher/wiki/Registration-of-JS-engines" style="background-color: white; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px;" target="_blank">this post </a> were Andrey Taritsyn describes how to register Reactjs.net with Chakracore and test it on the server. but it still didn't work. After some more digging, I found out that even though <b>JavaScriptEngineSwitcher.ChakraCore </b>is in the packages, there is no dependency to <b>Microsoft.ChakraCore </b> and therefore it cannot find the related dll for it :|.</div>
<div style="box-sizing: border-box;">
<br /></div>
<h3 style="box-sizing: border-box;">
Finding What is wrong</h3>
<div style="box-sizing: border-box;">
Reactjs.net uses <a href="https://msdn.microsoft.com/en-us/library/sk36c28t(v=vs.110).aspx">System.Diagnostics.Trace</a> to log the errors. Since you do not have access to console on test/ prod environment, you can just enable it to write to a log file:</div>
<div style="box-sizing: border-box;">
<br /></div>
<div style="box-sizing: border-box;">
To do so, go to web.config and add this:</div>
<pre class="brush: csharp">
<configuration>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="log" type="System.Diagnostics.TextWriterTraceListener" initializeData="output.log" />
</listeners>
</trace>
</system.diagnostics>
</configuration></pre>
<br /></div>
</div>
<h3 style="box-sizing: border-box;">
The solution</h3>
<div style="box-sizing: border-box;">
</div>
<ol>
<li> add <a href="https://www.nuget.org/packages/Microsoft.ChakraCore/">Microsoft.ChakraCore</a> nuget package</li>
<li> in your visual studio, go to App_start folder and create a class JsEngineSwitcherConfig</li>
<br />
<div>
<pre class="brush: csharp">
public class JsEngineSwitcherConfig
{
public static void Configure(JsEngineSwitcher engineSwitcher)
{
engineSwitcher.EngineFactories
.AddChakraCore()
//.AddJint() //only if needed
//.AddJurassic()//only if needed
.AddMsie(new MsieSettings
{
UseEcmaScript5Polyfill = true,
UseJson2Library = true
})
.AddV8()
;
engineSwitcher.DefaultEngineName = ChakraCoreJsEngine.EngineName;
}
}</pre>
</div>
<div>
<br /></div>
<div>
<br />
<li> Go to the Application_Start on Global.asax.cs and then add configure method to it. it should look like this:</li>
</div>
<pre class="brush: csharp">
protected void Application_Start()
{
.....
RouteConfig.RegisterRoutes(RouteTable.Routes);
JsEngineSwitcherConfig.Configure(JsEngineSwitcher.Instance);
.......
}</pre>
</ol>
<div>
<br /></div>
<div>
<br /></div>
<div>
You are good to go 😀</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com4tag:blogger.com,1999:blog-9132129770667485834.post-70780714303413582412017-02-15T23:39:00.002-08:002017-02-15T23:52:15.390-08:00Testing Vimeo background videoLets try Vimeo as a background for a page.<br />
<br />
I've found a short post in here and it seems to be interesting. :)<br />
<a href="https://vimeo.com/forums/feature_requests/topic:278001">https://vimeo.com/forums/feature_requests/topic:278001</a><br />
<br />
The code is like this:<br />
<pre class="sticky_code" style="font-family: consolas, "liberation mono", courier, monospace; font-size: 14px; line-height: 19px; margin-bottom: 10px; padding: 0px 10px; white-space: pre-wrap;"><code class="rainbow" data-language="html" style="border-radius: 0px; border: 0px; font-family: consolas, "liberation mono", courier, monospace; font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px; padding: 0px;"><span class="support tag" style="background-color: #e9f7fb; color: navy;"><span class="support tag"><</span><span class="support tag-name">iframe</span></span><span style="background-color: #e9f7fb; color: #112233;"> </span><span class="support attribute" style="background-color: #e9f7fb; color: teal;">src</span><span class="support operator" style="background-color: #e9f7fb; color: #0086b3;">=</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span class="string value" style="background-color: #e9f7fb; color: #aad450;">https://player.vimeo.com/video/76979871</span><span class="string value" style="background-color: yellow;">?background=1</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span style="background-color: #e9f7fb; color: #112233;"> </span><span class="support attribute" style="background-color: #e9f7fb; color: teal;">width</span><span class="support operator" style="background-color: #e9f7fb; color: #0086b3;">=</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span class="string value" style="background-color: #e9f7fb; color: #aad450;">500</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span style="background-color: #e9f7fb; color: #112233;"> </span><span class="support attribute" style="background-color: #e9f7fb; color: teal;">height</span><span class="support operator" style="background-color: #e9f7fb; color: #0086b3;">=</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span class="string value" style="background-color: #e9f7fb; color: #aad450;">281</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span style="background-color: #e9f7fb; color: #112233;"> </span><span class="support attribute" style="background-color: #e9f7fb; color: teal;">frameborder</span><span class="support operator" style="background-color: #e9f7fb; color: #0086b3;">=</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span class="string value" style="background-color: #e9f7fb; color: #aad450;">0</span><span class="string quote" style="background-color: #e9f7fb; color: #aad450;">"</span><span style="background-color: #e9f7fb; color: #112233;"> webkitallowfullscreen mozallowfullscreen allowfullscreen</span><span class="support tag close" style="background-color: #e9f7fb; color: navy;">></span><span class="support tag" style="background-color: #e9f7fb; color: navy;"><span class="support tag"><</span><span class="support tag special">/</span><span class="support tag-name">iframe</span></span><span class="support tag close" style="background-color: #e9f7fb; color: navy;">></span></code></pre>
You may need to pay attention to background=1 in the querystring.<br />
<br />
<b><span style="font-size: large;">P.S: I don't have a Vimeo account :)</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
<br />
<iframe allowfullscreen="" frameborder="0" height="281" mozallowfullscreen="" src="https://player.vimeo.com/video/76979871?background=1" webkitallowfullscreen="" width="500"></iframe><br />
<br />
<br />
<br />
<br />
Another sample:<br />
<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="360" mozallowfullscreen="" src="https://player.vimeo.com/video/203671501?background=1" webkitallowfullscreen="" width="640"></iframe>
<br />
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com3tag:blogger.com,1999:blog-9132129770667485834.post-33980227427091516142017-02-09T11:12:00.000-08:002017-02-09T11:22:55.047-08:00Surrounding EpiServer lines with a div in content area<br />
<h2>
Surrounding EpiServer lines with a div in content area</h2>
Some days ago I had a discussion with our frontenders 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:<br />
I will use Alloy Demo site to describe the issue and my solution<br />
<br />
<h3>
<b>The problem:</b></h3>
<div>
In a ContentArea, if you add some items it will be a big div with multiple lines inside. </div>
<div>
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 are in the third line. And size of each block depends on their display options.</div>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN9EwfSb4uNZ0o1A67wX-6zIxsws_Aoj6LgNFSYyyEESGF57e7ryXKJrGizBRC2bfgSnwjVVmOnguAWfa8vqE29mS2xr0C03xB1j3Sgy9Y-IMJHGplMAkquumnfF0Rrnf-hhSx0EdILDM/s1600/alloy.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN9EwfSb4uNZ0o1A67wX-6zIxsws_Aoj6LgNFSYyyEESGF57e7ryXKJrGizBRC2bfgSnwjVVmOnguAWfa8vqE29mS2xr0C03xB1j3Sgy9Y-IMJHGplMAkquumnfF0Rrnf-hhSx0EdILDM/s640/alloy.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<h3>
The request</h3>
<div>
Surrounding each line with a div with CssClass="row" and removing the one for content area.</div>
<div>
<br /></div>
<h3>
The solution</h3>
<div>
Removing the css class from the ContentArea is too easy since it has been added to html.Propertyfor in the index page:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOZuQ-KQZ8bgB8Oh6Pa2LGLlmHWbQhs8aez7jJjA1ZxyTlmrsQlMi6RL1yDZ6OBlF8jSKQS12xfp-ffDoeALlOI-LdX_KaaD0QRrOXlSQ8fK8EAFDHBxe5SK4mttdlR0V2AswnAaF_VjY/s1600/allo2y.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="38" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOZuQ-KQZ8bgB8Oh6Pa2LGLlmHWbQhs8aez7jJjA1ZxyTlmrsQlMi6RL1yDZ6OBlF8jSKQS12xfp-ffDoeALlOI-LdX_KaaD0QRrOXlSQ8fK8EAFDHBxe5SK4mttdlR0V2AswnAaF_VjY/s640/allo2y.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
However to remove add the container around each row, you need to override ContentAreaRenderer. In alloy demo website, it has already been overridden to add suitable classes based on the tags and it is called AlloyContentAreaRenderer. Just override RenderContentAreaItems method and add this code. Then you are good to go :)</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ7Jh114Am3jaikojJJJAvqpO_7OIyVmtohhWOvniuu9vY7ykz8q87WkverdbbiRamKdqVhgy9IxXl50ju16lo5ILVIKHfi1SSFYUidQ7gfycETOI1UvVcXCt_y3uwDHcvaVf2sBaEA0c/s1600/alloy4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="432" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ7Jh114Am3jaikojJJJAvqpO_7OIyVmtohhWOvniuu9vY7ykz8q87WkverdbbiRamKdqVhgy9IxXl50ju16lo5ILVIKHfi1SSFYUidQ7gfycETOI1UvVcXCt_y3uwDHcvaVf2sBaEA0c/s640/alloy4.png" width="640" /></a></div>
<div>
<br /></div>
<pre class="brush: csharp"> protected override void RenderContentAreaItems(HtmlHelper htmlHelper, IEnumerable<contentareaitem> contentAreaItems)
{
float totalSize = 0;
if (contentAreaItems.Any())
htmlHelper.ViewContext.Writer.Write(@"<div class="" row="">
");
foreach (ContentAreaItem contentAreaItem in contentAreaItems)
{
var tag = this.GetContentAreaItemTemplateTag(htmlHelper, contentAreaItem);
totalSize += GetSize(tag);
if (totalSize>1)
{
htmlHelper.ViewContext.Writer.Write(@"</div>
<div class="" row="">
");
totalSize = GetSize(tag);
}
this.RenderContentAreaItem(htmlHelper, contentAreaItem,
this.GetContentAreaItemTemplateTag(htmlHelper, contentAreaItem),
this.GetContentAreaItemHtmlTag(htmlHelper, contentAreaItem),
this.GetContentAreaItemCssClass(htmlHelper, contentAreaItem));
}
if (contentAreaItems.Any())
htmlHelper.ViewContext.Writer.Write(@"</div>
");
}
float GetSize(string tagName)
{
if (string.IsNullOrEmpty(tagName))
{
return 1f;
}
switch (tagName.ToLower())
{
case "span12":
return 1f;
case "span8":
return 0.666666f;
case "span6":
return 0.5f;
case "span4":
return 0.333333f;
default:
return 1f;
}
}
</contentareaitem></pre>
<div>
<div>
<div>
</div>
</div>
</div>
<h3>
The result</h3>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI-YBEkEiB8YwtSqZTTrE5iEKoB-ScIKJ-HCV-xhq-JStgUvtOplF1kxUD9vOslIH_5gx5zDjpFqC4L4JsqPd-w8J_2nRumU6NeaPJ4csY1F-MSfRo7sCHmHXQJ1vmCDmwyiQxkknHwhM/s1600/alloy3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI-YBEkEiB8YwtSqZTTrE5iEKoB-ScIKJ-HCV-xhq-JStgUvtOplF1kxUD9vOslIH_5gx5zDjpFqC4L4JsqPd-w8J_2nRumU6NeaPJ4csY1F-MSfRo7sCHmHXQJ1vmCDmwyiQxkknHwhM/s640/alloy3.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com19tag:blogger.com,1999:blog-9132129770667485834.post-26078231950951457802016-07-21T07:20:00.003-07:002016-07-21T07:20:26.903-07:00Microsoft Service bus: Queue, Topic and Event Hub<h1 id="Queue,TopicandEventHub-SelectingbetweenQueue,TopicandEventHub:" style="background-color: white; border-bottom-color: rgb(204, 204, 204); color: #333333; font-family: Arial, sans-serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px; padding: 0px;">
<strong>Selecting between Queue, Topic and Event Hub:</strong></h1>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRfMirArCrvgS-WFTb5eNBcJePkPi9-ev4W-xL7Qlf2Y1xaIUciQONEXhT58cNJOBvwwTINmSC0aXwB00eRhWWdvUeA21FiBUysF6oNba26rK7yQD3qnkKWurYyf34imTJ_OcpT50dRE4/s1600/service+bus+namespace.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRfMirArCrvgS-WFTb5eNBcJePkPi9-ev4W-xL7Qlf2Y1xaIUciQONEXhT58cNJOBvwwTINmSC0aXwB00eRhWWdvUeA21FiBUysF6oNba26rK7yQD3qnkKWurYyf34imTJ_OcpT50dRE4/s320/service+bus+namespace.png" width="320" /></a></div>
<h2 id="Queue,TopicandEventHub-Usage:" style="background-color: white; border-bottom-color: rgb(204, 204, 204); color: #333333; font-family: Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
<br /></h2>
<h2 id="Queue,TopicandEventHub-Usage:" style="background-color: white; border-bottom-color: rgb(204, 204, 204); color: #333333; font-family: Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Usage:</h2>
<h3 id="Queue,TopicandEventHub-Queue:" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 10px 0px 0px; padding: 0px;">
Queue:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
The scenario for queue is almost clear. Each message will be receive only by 1 receiver.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Of course it is possible to have multiple senders and multiple receivers, but the key point is that each message will receive only to one of those receivers.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqfSZCibjueiP2-Pyh4J-nizdUOAI8mOFlS50pp4g7FmNLZKg38AyFMOFbzHHlJWLyzfxwgV2z7IOHLmIephL0OU6CaF_mmE1dt-c7KhrlMhcEDdX_kGJQsJHAx1j7nMYbGSnL1sGUZ8k/s1600/queue.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqfSZCibjueiP2-Pyh4J-nizdUOAI8mOFlS50pp4g7FmNLZKg38AyFMOFbzHHlJWLyzfxwgV2z7IOHLmIephL0OU6CaF_mmE1dt-c7KhrlMhcEDdX_kGJQsJHAx1j7nMYbGSnL1sGUZ8k/s320/queue.png" width="320" /></a></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"></span></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
A simple example of using queues is POS (point of sale) systems. POS terminals produce some data with different load/times and the inventory management system has to process all of them. The inventory system and the Terminals are loosely coupled there might be different softwares in each terminal, but there is only 1 receiver on the other end.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcAzFBvWQto6lOwOY26fenIWRaQDVlNPFnF6KQNkCDqTsnCK_PBPwv8sW8_mJOhuKns3ec8-hcV9dDvBD30TnsPEhah9PTIiPvwzN6krEvpQkMVBETrYV7zGyIutoyENEGvlWHC5cfejs/s1600/queueExample.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcAzFBvWQto6lOwOY26fenIWRaQDVlNPFnF6KQNkCDqTsnCK_PBPwv8sW8_mJOhuKns3ec8-hcV9dDvBD30TnsPEhah9PTIiPvwzN6krEvpQkMVBETrYV7zGyIutoyENEGvlWHC5cfejs/s320/queueExample.gif" width="320" /></a></div>
<h3 id="Queue,TopicandEventHub-Topic-subscription:" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Topic-subscription:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
This type of queue will be used when a <strong>single</strong> message has to be received by multiple receivers. It is also possible to differentiate between receivers so a group of receivers will only receive special types of messages.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
The same as queues, there can be multiple instances of sender/receivers (multiple receiver per subscription) is available, but when a receiver reads data from 1 subscription, the others cannot read it again from the same subscription.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
A simple example for this scenario is logging/Search. You want to have an instance of your data to use in a logging (search) system, but there has to be no relation between your realtime system with the logging system rationally.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUuoAexC4MOaKW_ZNBDSsccgt-beSvJamTX7WdKOwmVWjCwASHc0Gzas1dkgRq0FYdPmXYMIVr1womRCVRfptke4k58WYbUZ7Rg_m5-WZ8z9-xo_qaU9isHifrgEzd0XdAUrfEXhUaUI0/s1600/topic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUuoAexC4MOaKW_ZNBDSsccgt-beSvJamTX7WdKOwmVWjCwASHc0Gzas1dkgRq0FYdPmXYMIVr1womRCVRfptke4k58WYbUZ7Rg_m5-WZ8z9-xo_qaU9isHifrgEzd0XdAUrfEXhUaUI0/s320/topic.png" width="320" /></a></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
The second scenario is also possible when you want to divide your messages into different lines. Like when you want to create a priority queue, or when a set of producers produce data for different systems. </div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
A simple example for this would be when you create data in a way and process them in different manners. For instance if there is an ordering system registers orders for different companies, then each company only needs to know about its orders.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"></span></div>
<h3 id="Queue,TopicandEventHub-Event-Hub:" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Event-Hub:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Event Hub is simply a big stream of data. In a way, Event hub is the answer for the same issues that we addressed in the Topics. There are multiple consumers for each message, but the big difference is that Event-hub has been implemented for maximizing the throughput.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Each Topic in event hub will multiple partitions (normally between 4 to 16) and 1 instance of the client will read from each partition. If any of the clients goes down or there are less clients that the partitions, clients will compete against each other to access to more partitions.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXEe6Rc1LpEMu-W9eWZHPuov9qWoBDUnE5Ix56dUQan7Q3v-uxF8UQFfNFNWUdKEVkVJlYk-o84Xw7wFamveJrwEIKS94wLjdn6PRFzClXiYC7SpYBwAHJQn3clVfBE78bAdcFS0nljSk/s1600/Hub.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXEe6Rc1LpEMu-W9eWZHPuov9qWoBDUnE5Ix56dUQan7Q3v-uxF8UQFfNFNWUdKEVkVJlYk-o84Xw7wFamveJrwEIKS94wLjdn6PRFzClXiYC7SpYBwAHJQn3clVfBE78bAdcFS0nljSk/s320/Hub.png" width="320" /></a></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
A simple scenario for this solution is logging players actions in a popular game. </div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<span class="confluence-embedded-file-wrapper confluence-embedded-manual-size" style="display: inline-block; max-width: none; position: relative;"></span></div>
<h2 id="Queue,TopicandEventHub-HowtheyAccessdata" style="background-color: white; border-bottom-color: rgb(204, 204, 204); color: #333333; font-family: Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
How they Access data</h2>
<h3 id="Queue,TopicandEventHub-Queue:.1" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 10px 0px 0px; padding: 0px;">
Queue:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
There is only 1 line of messages. Clients wait for a message and when a new message received, only one of them will process it.</div>
<h3 id="Queue,TopicandEventHub-Topic-subscription:.1" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Topic-subscription:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
There is only multiple lines of subscriptions. Clients of a subscription wait for data and the same scenario as queues happens here. It is important to note that there is no relation between data in different subscriptions.</div>
<h3 id="Queue,TopicandEventHub-Event-Hub:.1" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Event-Hub:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Clients are responsible for the data that they read. Meaning that it is possible for different clients to read a message multiple time. Messages would not remove from system until a reasonable time (some days), or depending on size of data. </div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Each client will ask the hub for data after special message (check point) so it is very possible to see some messages has been read multiple time when a client restarts.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
There is a concept of Consumer Groups which is almost the same as subscription in the topic base service bus.</div>
<h2 id="Queue,TopicandEventHub-Howtomanagefailure" style="background-color: white; border-bottom-color: rgb(204, 204, 204); color: #333333; font-family: Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
How to manage failure</h2>
<h3 id="Queue,TopicandEventHub-Topic-subscription:.2" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 10px 0px 0px; padding: 0px;">
Topic-subscription:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
There is 2 ways of receiving a message:</div>
<h4 id="Queue,TopicandEventHub-1-PeekLock(default)" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin: 20px 0px 0px; padding: 0px;">
1- PeekLock (default)</h4>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Data will be read by the client and it will be locked for some time. When the client finished its work, it simply tells to the broker that and the broker will remove the item from queue.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
If an error happens in the process client can abandon the message, therefore another client would read the same message later on in case that the error was temporary.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Also, if the client crashes in the middle of the process, the lock will be time outed and the message will be readable for another client.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<h4 id="Queue,TopicandEventHub-2-ReceiveAndDelete" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin: 20px 0px 0px; padding: 0px;">
2-ReceiveAndDelete</h4>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
The broker doesn't care about the probable errors. It simply say the message will be read <strong>1 times max</strong>!</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<h3 id="Queue,TopicandEventHub-Event-Hub:.2" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Event-Hub:</h3>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Messages will be in the hub for a long time, so we can be sure that data will be read by clients <strong>at least 1 time</strong>. </div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Each client will set a check point after a portion of time (or any rule that the clients decides) and if it restarts, it will continue reading from that checkpoint again. So the client has to take care of duplicates it self.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
<h2 id="Queue,TopicandEventHub-InstallationEnvironment" style="background-color: white; border-bottom-color: rgb(204, 204, 204); color: #333333; font-family: Arial, sans-serif; font-size: 20px; font-weight: normal; line-height: 1.5; margin: 30px 0px 0px; padding: 0px;">
Installation Environment</h2>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
Queue and Topic-subscription are available on both Microsoft Azure (cloud) and on premise but Event-Hub is only available on the Azure.</div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; line-height: 20px; margin-top: 10px; padding: 0px;">
<span style="font-size: large;"><br /></span></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; line-height: 20px; margin-top: 10px; padding: 0px;">
<span style="font-size: large;">Read More</span></div>
<a href="https://azure.microsoft.com/en-us/documentation/articles/event-hubs-overview/" target="_blank">Azure Event Hubs overview</a><div>
<a href="https://azure.microsoft.com/en-us/documentation/articles/service-bus-create-queues/" target="_blank">Create applications that use Service Bus queues</a><div>
<a href="http://microsoftintegration.guru/2015/03/03/azure-event-hubs-vs-azure-messaging/" target="_blank">Azure Event Hubs vs Azure Messaging</a></div>
<div>
<a href="https://blogs.msdn.microsoft.com/servicebus/2015/01/16/event-processor-host-best-practices-part-1/" target="_blank">Event Processor Host Best Practices</a><div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
* Pictures for this post have been copied from <a href="https://azure.microsoft.com/en-us/documentation/articles/service-bus-create-queues/" target="_blank">here </a>and <a href="http://microsoftintegration.guru/2015/03/03/azure-event-hubs-vs-azure-messaging/" target="_blank">here</a></div>
<div style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; margin-top: 10px; padding: 0px;">
<br /></div>
</div>
</div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com31tag:blogger.com,1999:blog-9132129770667485834.post-13378621408546129572016-07-18T04:10:00.001-07:002016-07-18T04:14:14.699-07:00Creating an email template engine - Part 1<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPfjFCSXF_oqlNb2-LpfgSWlvt6koTZbSmo49rqFzEK3ptnpCbBGirxQavXXuKSQ6VLDAWMzJU_GqPhHHcGcVe5tZD7KceH1hZXX_oXvt6t4CDdJFk5TvM3BUY4GKlFgR-6swrMR4Pu1o/s1600/email.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPfjFCSXF_oqlNb2-LpfgSWlvt6koTZbSmo49rqFzEK3ptnpCbBGirxQavXXuKSQ6VLDAWMzJU_GqPhHHcGcVe5tZD7KceH1hZXX_oXvt6t4CDdJFk5TvM3BUY4GKlFgR-6swrMR4Pu1o/s320/email.jpg" width="320" /></a></div>
<span style="font-size: large;"><b>Introduction</b></span><br />
<br />
Sending emails is always one of the jobs that most customers want. Sometimes they want to send a welcome letter or some notifications or even a newsletter for the customers and so they ask for a module that they can use. Writing a method for sending emails takes less than 10 seconds these days (<br />
SmtpClient.Send :) ) but creating a good content that can be flexible enough for the client to use and at the same time not much complex that make them suffer is a bit tricky. So In this post I will show you how to do it in a simple way.<br />
<div>
<br /></div>
<div>
<b><span style="font-size: large;">Dividing the content</span></b></div>
<div>
<br />
If you ask a client what content will you have in your emails, they will probably say everything is possible but they usually want to have the same design on most of their emails. It is a way to show that all of those emails are from the same company. Also, the one who writes the email content usually doesn't have any knowledge about the design, and you don't want to let him mess up with the CSS.<br />
So in short you have these contents inside your email engine:<br />
1- A HTML/CSS design form<br />
2- Some placeholders for special data like customer name, Date, etc.<br />
3- Some content that changes by the editor</div>
<div>
<br /></div>
<div>
<span style="font-size: large;"><b>Using MVC engine</b></span></div>
<div>
<br />
Usually whenever we talk about HTML/CSS design, we think of how we do it using MVC, because as web developers that is what we do. By using MVC, we always separate our business from the view. Right? We never write anything inside the view so if the customer doesn't like the look of his pages, or if there was a change in theme or etc. it could be possible without us doing anything. And let me add that doing the front-end usually needs a good eye to see what is pretty and I myself don't have it :)<br />
So, why not using MVC engine to create our email body? It is only a simple HTML page noting more.<br />
<br />
<b><span style="font-size: large;">Replacing the placeholders </span></b><br />
<br />
String processing is very easy in all programming languages, you just need to define strings that no one will use in a text. Something simple like having names with double hash in both sides like ##SomeName## will probably do the task. You can also use the simple string.Replace method but for the sake of both speed and flexibility I choose to work with RegEx library most of the time.<br />
<br />
<b><span style="font-size: large;">Implementing the code</span></b><br />
<br />
<span style="font-size: large;">Rendering the MVC view to string:</span><br />
<br />
There is a very good <a href="https://weblog.west-wind.com/posts/2012/May/30/Rendering-ASPNET-MVC-Views-to-String" target="_blank">post by Rick Strahl </a>. He basically wrote a class to help him do some of the stuff easily:<br />
<pre class="brush: csharp">public class ViewRenderer
{
protected ControllerContext Context { get; set; }
public ViewRenderer(ControllerContext controllerContext = null)
{
if (controllerContext == null)
{
if (HttpContext.Current != null)
controllerContext = CreateController<emailsendercontroller>().ControllerContext;
else
throw new InvalidOperationException(
"ViewRenderer must run in the context of an ASP.NET " +
"Application and requires HttpContext.Current to be present.");
}
Context = controllerContext;
}
public string RenderView(string viewPath, object model)
{
return RenderViewToStringInternal(viewPath, model, false);
}
public string RenderPartialView(string viewPath, object model)
{
return RenderViewToStringInternal(viewPath, model, true);
}
public static string RenderView(string viewPath, object model,
ControllerContext controllerContext)
{
ViewRenderer renderer = new ViewRenderer(controllerContext);
return renderer.RenderView(viewPath, model);
}
public static string RenderPartialView(string viewPath, object model,
ControllerContext controllerContext)
{
ViewRenderer renderer = new ViewRenderer(controllerContext);
return renderer.RenderPartialView(viewPath, model);
}
protected string RenderViewToStringInternal(string viewPath, object model,
bool partial = false)
{
ViewEngineResult viewEngineResult = null;
if (partial)
viewEngineResult = ViewEngines.Engines.FindPartialView(Context, viewPath);
else
viewEngineResult = ViewEngines.Engines.FindView(Context, viewPath, null);
if (viewEngineResult == null)
throw new FileNotFoundException("View did not find!");
var view = viewEngineResult.View;
Context.Controller.ViewData.Model = model;
string result = null;
using (var sw = new StringWriter())
{
var ctx = new ViewContext(Context, view,
Context.Controller.ViewData,
Context.Controller.TempData,
sw);
view.Render(ctx, sw);
result = sw.ToString();
}
return result;
}
public static T CreateController<t>(RouteData routeData = null)
where T : Controller, new()
{
T controller = new T();
HttpContextBase wrapper = null;
if (HttpContext.Current != null)
wrapper = new HttpContextWrapper(System.Web.HttpContext.Current);
if (routeData == null)
routeData = new RouteData();
if (!routeData.Values.ContainsKey("controller") && !routeData.Values.ContainsKey("Controller"))
routeData.Values.Add("controller", controller.GetType().Name
.ToLower()
.Replace("controller", ""));
controller.ControllerContext = new ControllerContext(wrapper, routeData, controller);
return controller;
}
}
</t></emailsendercontroller></pre>
<pre class="brush: csharp"></pre>
</div>
This class works very good giving you the opportunity to render your Razor view to HTML string.<br />
<br />
<span style="font-size: large;">Creating the viewModel</span><br />
To work with MVC, you need to have a model to pass to the view and then in the view the designer knows what he has to create a good view.<br />
<br />
Create a EmailTemplateBase so you can use it for different views depending on what you need to do and put your base stuff inside that. something like:<br />
<pre class="brush: csharp">public class EmailTemplateBase
{
public string Markup { get; set; }
public string BodyTextMarkup { get; set; }
}</pre>
<br />
Then you can inherit from it to have your special view or just use it as your view model.<br />
<span style="font-size: large;">Creating the Controller</span><br />
Since we are using the .Net MVC, it is not possible to generate stuff without using a controller. So just create a simple controller:<br />
<pre class="brush: csharp">public class mycontroller
{
public ActionResult Index(EmailTemplateBase model)
{
return View(model);
}
}
</pre>
<br />
<span style="font-size: large;">Creating the view</span><br />
It is the simple Razor MVC view and the viewmodel is the one that you've already created so I won't bother writing that :)<br />
<br />
<span style="font-size: large;">Replacing the name value tokens</span><br />
<br />
I myself prefer to have this method in a helper class with extension methods so I can use it like text.ReplaceTokens(collection) but you can use it as a simple method without extentions.
<br />
<pre class="brush: csharp">public static string ReplaceTokens(this string text, NameValueCollection nameValueCollection)
{
foreach (var key in nameValueCollection.AllKeys)
{
var replacementText = nameValueCollection[key] ?? "";
text = Regex.Replace(text, key, replacementText, RegexOptions.IgnoreCase);
}
return text;
}
</pre>
<pre class="brush: csharp"></pre>
<span style="font-size: large;">Creating the Email Body</span><br />
To create the email body, you need to get the body markup from the DB where you put bodytext that you already took from the editor. also you need to have a list of namevalues that you want to replace somewhere. The namevalue collection has to have everything that is possible for the editor to use, but it has to be ok for him not using some or all of them.<br />
<br />
<pre class="brush: csharp">public string CreateEmail(string bodyMarkupText, NameValueCollection tokenCollection)
{
var url = "~/views/myPage/Index.cshtml";
var model = new ReceiptViewModel()
{
BodyTextMarkup = bodyMarkupText
};
var bodyText = ViewRenderer.RenderView(url, model, null);
return bodyText.ReplaceTokens(tokenCollection);
}
</pre>
<div>
<br /></div>
Now you just need to put the string as the email body and send the email to the user :)<br />
Easy right?<br />
Have fun :)Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com2tag:blogger.com,1999:blog-9132129770667485834.post-2422269269392066142016-07-14T07:38:00.002-07:002016-07-14T07:38:36.227-07:00EPiServer for beginers, where is version historyVersion 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.<br />
You might say that everyone knows that EPiServer has this feature, but to be honest I didn't expect to find it inside the gadgets pane the first time, so I thought why not mentioning it for beginners :)<br />
<br />
<br />
So to see the version history follow these steps:<br />
1- In the editors page find the settings button on top right of your pane.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLadHezqjGbueZzG85MnaL90KVV0hYPAHnqs7txLWupBze-V3WXkeupVQm3cgaX21I9oW9498EjJOl7byMo9QCtzZILYbci9c-b5KzD-zq7QPFpzFT-6xq0zKAEroOf_ogM6NEwUv2OyQ/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLadHezqjGbueZzG85MnaL90KVV0hYPAHnqs7txLWupBze-V3WXkeupVQm3cgaX21I9oW9498EjJOl7byMo9QCtzZILYbci9c-b5KzD-zq7QPFpzFT-6xq0zKAEroOf_ogM6NEwUv2OyQ/s1600/1.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
2- click on add gadgets</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
3- select "versions" gadget from the list</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihg3ANyV-Gf0Y1zQBZhbtKmwUQrLISfUNXEOrtql9_S0Sv50Rk9piaNeF66Joz9hATZ83gSRIEa4APjs2Ad3FDd6R1bvyX8_ARVmPWl4Gg7MaefyYucrX1Fdy7KU_4deNrn-rgsgcrF9I/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihg3ANyV-Gf0Y1zQBZhbtKmwUQrLISfUNXEOrtql9_S0Sv50Rk9piaNeF66Joz9hATZ83gSRIEa4APjs2Ad3FDd6R1bvyX8_ARVmPWl4Gg7MaefyYucrX1Fdy7KU_4deNrn-rgsgcrF9I/s320/2.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
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 :)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtBT3jF972TYB-6OtzgWxleEbPLsuEymdV2wr1UNSn2Ba6CKuq7LFfTtLvUQxR6VBh_txDsR04jEfadZMvu5N7vcPuHeJg4IU7B_SOty5Px8S4dX4-PAlzHeYlXHqOlaNQ7N3KojFbTog/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtBT3jF972TYB-6OtzgWxleEbPLsuEymdV2wr1UNSn2Ba6CKuq7LFfTtLvUQxR6VBh_txDsR04jEfadZMvu5N7vcPuHeJg4IU7B_SOty5Px8S4dX4-PAlzHeYlXHqOlaNQ7N3KojFbTog/s1600/3.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com19tag:blogger.com,1999:blog-9132129770667485834.post-16968282643398817512016-07-07T05:21:00.001-07:002016-07-07T06:27:39.328-07:00Umbraco: Adding Gibe Link Picker to Macro parameters<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqGlBocnn60r0MSYY0mudVFbcbNyo3upPpCbhCnk8rRGRKl5Q-UpdfZaeix_emfFyn0AVXUxL6NqdOzRSe857asyUOo65gh8jbJjaNDJd5kzyXOW79izMcSvsF1xXDpMHl1gXMVv2Pjss/s1600/linkpicker2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqGlBocnn60r0MSYY0mudVFbcbNyo3upPpCbhCnk8rRGRKl5Q-UpdfZaeix_emfFyn0AVXUxL6NqdOzRSe857asyUOo65gh8jbJjaNDJd5kzyXOW79izMcSvsF1xXDpMHl1gXMVv2Pjss/s320/linkpicker2.png" width="311" /></a></div>
<br />
Gabe link picker is one of the coolest add-ons available for Umbraco 7. By installing it, you will have the option to select a link from inside your Umbraco project, or write the URL your self for an external link/mailto. You can read more about downloading/ using it from <a href="https://our.umbraco.org/projects/backoffice-extensions/link-picker/" target="_blank">here</a>.<br />
<br />
However, one might want to use the link picker as macro parameter. To do so,go to your solution-> app_plugins>GabeLinkPicker>package.manifest<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKNyD74EtVhchISp6alDB4KbaQgiTMJv8Z_QRYEtuIQISK_zER8OOvirgdvi8WPOZyBilMYbkwaL_UGTaQARKCCEZS9aFAlyJdPNifL_jFhq-qLNchuPN7h4h6yc1VLdBO9I1nf2myRJo/s1600/gabe.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="159" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKNyD74EtVhchISp6alDB4KbaQgiTMJv8Z_QRYEtuIQISK_zER8OOvirgdvi8WPOZyBilMYbkwaL_UGTaQARKCCEZS9aFAlyJdPNifL_jFhq-qLNchuPN7h4h6yc1VLdBO9I1nf2myRJo/s320/gabe.png" width="320" /></a></div>
<br />
and then add isParameterEditor: true to the property editor. It should look like this:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsrsD3tCQz2TJIsVTEPt6wEG6s-O_kwia5Syo8UQ3IVfmCEsLVWt3qFubxWlnCaQnWrH7PIHconu7GZ8aUQBarUzY795j8gGek9Wv1LlJJF0UcKo94qKOcUWTRGmYvt3z2eoxkoNtHihA/s1600/parameter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsrsD3tCQz2TJIsVTEPt6wEG6s-O_kwia5Syo8UQ3IVfmCEsLVWt3qFubxWlnCaQnWrH7PIHconu7GZ8aUQBarUzY795j8gGek9Wv1LlJJF0UcKo94qKOcUWTRGmYvt3z2eoxkoNtHihA/s320/parameter.png" width="320" /></a></div>
<br />
Now if you open a macro type(or create one) and go to parameters tab, link picker will be one of your options as the parameter type.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimKZZCFaO6wjMsCq-n0RcHFOwj0ebur3JvsN6bMmH5aY_9PXYGplQrHIS25kFE4dda2cKha1_cKZzJb-X4CKPPSM-zjGDav2ybw4rl6tNBahlsqOG-u-dl-om0pZRXT6dTu-ts3DWhRoE/s1600/linkpicker.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="51" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimKZZCFaO6wjMsCq-n0RcHFOwj0ebur3JvsN6bMmH5aY_9PXYGplQrHIS25kFE4dda2cKha1_cKZzJb-X4CKPPSM-zjGDav2ybw4rl6tNBahlsqOG-u-dl-om0pZRXT6dTu-ts3DWhRoE/s640/linkpicker.png" width="640" /></a></div>
<br />
<br />
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com1tag:blogger.com,1999:blog-9132129770667485834.post-66360254722469461732016-07-05T05:02:00.002-07:002016-07-05T05:02:32.349-07:00umbracoRedirect The great hidden Property<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq7JXSPQz89Y_h-1XdU71OQFMUZDtSu85zc5-tnL8gHBYddT5kqATyYjQ5L8Pzt9LWTIRVZN-U8nH4co409U-cbJlJPno67CvWjjJnAyJbS-mzNAjseW8P-BiKjRokaribos0iLx0sy4w/s1600/2016_07_05_13_50_17_content_dev.insilico.dk.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="115" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq7JXSPQz89Y_h-1XdU71OQFMUZDtSu85zc5-tnL8gHBYddT5kqATyYjQ5L8Pzt9LWTIRVZN-U8nH4co409U-cbJlJPno67CvWjjJnAyJbS-mzNAjseW8P-BiKjRokaribos0iLx0sy4w/s320/2016_07_05_13_50_17_content_dev.insilico.dk.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I had a scenario that I wanted to redirect a page to another one in my Umbraco solution. I needed my page to be in my structure, but I didn't want it to show anything and I didn't want its url to be shown on the address bar. Then my friend Niels Damkjær showed me a good hidden feature in Umbraco.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
There is no need to write code or do something hard. You just need to create a new field in your document type with alias <b>umbracoRedirect </b>and the editor has to be <b>Content Picker</b>. Thats all you need to do :) Something like this:</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjz5MTdXzT7NNbc-evDT3N1J-oHVdf7JJ1vJvh9F89yiTVM8s1zXA0AEmS2I2SDvnzLonjtGjo_Y04CWYedZW9_YlBnKcpDiDJp-Qm18E4njEXP9ZukQnAxG8l0ZOBhdjGz6ZhZFS75J3c/s1600/2016_07_05_13_54_21_settings_dev.insilico.dk.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="80" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjz5MTdXzT7NNbc-evDT3N1J-oHVdf7JJ1vJvh9F89yiTVM8s1zXA0AEmS2I2SDvnzLonjtGjo_Y04CWYedZW9_YlBnKcpDiDJp-Qm18E4njEXP9ZukQnAxG8l0ZOBhdjGz6ZhZFS75J3c/s320/2016_07_05_13_54_21_settings_dev.insilico.dk.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Then in your page you can select the tab for redirecting which is very cool. </div>
<div class="separator" style="clear: both; text-align: left;">
There is also a post in our Umbraco in <a href="https://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect" target="_blank">here</a> but you don't need to do it with those steps.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
* After adding the field for the first time, it did not work for me, but when I restart my webserver it started to work fine.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
* It uses the http 302 header to tel the browser to redirect to another page which is the temporary redirect command. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com28tag:blogger.com,1999:blog-9132129770667485834.post-8477066840118752742016-06-30T09:51:00.001-07:002017-02-09T11:12:12.903-08:00Beginners guide to Umbraco 7: A guide for developers Part 1<b><span style="font-size: large;">Introduction</span></b><br />
<br />
Some months ago, I've started to work with Umbraco. First I've tried to understand how it works and what do I need to know in order to implement good code with Umbraco, but actually it took more time than I've imagined.<br />
The reason is Umbraco is very flexible which makes it easy to work for content managers, front-enders, and us (C# developers, back-enders, full-stack developers). You can easily implement lots of stuff inside Umbraco without needing any IDE and there is no need to implement a controller, service or anything. So if you are using it to implement a simple website that doesn't need that much code implementation or software structure, there is no need to read my post :)<br />
<br />
<b><span style="font-size: large;">As a developer why do I need Umbraco (or any CMS)?</span></b><br />
If you want to develop some code on Umbraco, you probably have some user specific scenarios that you need to implement in your code and at the same time, you want to give some flexibility to the editors to use your structure and their creativity to make good content. For instance, recently I needed to create a rule engine in a project. It took me only a couple of hours to implement 4 different rule type, setting the consumers up and adding them to my pages. only 2 hours from A to Z :)<br />
<br />
<span style="font-size: large;"><b>Where to start?</b></span><br />
There are some videos in <a href="http://umbraco.tv/">http://umbraco.tv/</a>. Start from there and learn the structure of Umbraco and how it works. It is Then come back and continue this post :)<br />
You will learn:<br />
*What is Umbraco's back office<br />
*How to create content types<br />
*How to create templates<br />
*How to create content like pages<br />
*How to set up surface controller ( a controller with access to Umbraco Stuff)<br />
*How to set up a service<br />
<br />
You will not learn:<br />
*What is going on in Umbraco<br />
*The project structures for different kind of projects<br />
*Relating different stuff<br />
*Working with Strongly Typed items! Yeap,<br />
<br />
<b><span style="font-size: large;">Beginners stuff in short</span></b><br />
<b><span style="font-size: large;">Installing</span></b><br />
Creaete a new visual studio empty asp.net solution. Then go to nuget package manager and add UmbracoCms.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdDw5u6lkQaHgZWtLBhyphenhyphen4iOsk9AlVOTERt7r3STv1xLJGlzpeO4POMx4o8ELKT6h3pX7g78TrGsE-5MYp1tR2cTj7T96XcsnpLEdZWrtL-Q-M0Xl_NWHsv7zrWZHms-ZHrfOjNzqEJ5uE/s1600/nuget.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdDw5u6lkQaHgZWtLBhyphenhyphen4iOsk9AlVOTERt7r3STv1xLJGlzpeO4POMx4o8ELKT6h3pX7g78TrGsE-5MYp1tR2cTj7T96XcsnpLEdZWrtL-Q-M0Xl_NWHsv7zrWZHms-ZHrfOjNzqEJ5uE/s320/nuget.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
This will add the Umbraco files. Now click F5 to run the project and then continue the wizard to create your stuff inside your DB. for the matter of your test project, you can go on with the DB file and when you want to publish your solution on test/production environment, you can easily set up the SQL server to use the DB like any other ASP.net project.<br />
<b><br /></b>
<b><span style="font-size: large;">Umbraco Back office: </span></b><br />
The place that you can go and change stuff, create content type, create content and everything that is possible through a CMS.<br />
You can go to your back office by adding an Umbraco to your sites url:<br />
www.yoursitename.com/umbraco<br />
<span style="font-size: large;"><br /></span>
<b><span style="font-size: large;">Creating Content Type:</span></b><br />
It is obvious from its name :). It is basically your model/class definition. There are 2 different types of content types,:<br />
<br />
1- With template: meaning that you want to show them to people like your pages.<br />
2- Without template: when you don't want to show anything for that single item. like your settings, etc.<br />
<br />
You can create content types by going to settings> content types and create your type. Just click on ... in front of the content types and select what you want.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_eh5xWNEMVJ3her1hJLeoimgmED62fY-ASdsloQp1m6M6RCTiCqyPJumFOSwRC4omiyaraDdCwloZueluD7ugSQ8Uc7JB44BREMGVrvzHgtpp9gYfnmwgoxql6NWLeQfMLDfXVbRaD18/s1600/settings.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_eh5xWNEMVJ3her1hJLeoimgmED62fY-ASdsloQp1m6M6RCTiCqyPJumFOSwRC4omiyaraDdCwloZueluD7ugSQ8Uc7JB44BREMGVrvzHgtpp9gYfnmwgoxql6NWLeQfMLDfXVbRaD18/s320/settings.png" width="320" /></a></div>
<br />
Then add your fields to your type. and click save.<br />
For instance, let say that you want create a page to read my data from my text box in back office and write it to my start page. I will create a document type, and will call it something like "Test Doc Type".<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMuyHL58d_IHi7Bm5eZWAuYbiixljzI-a7O2AJD68UkTgbKYdKssYBME0g1lYOBBv_TvFGZ1wjOpXX5eFdSXrjvbbVs7Ysv9mv5Gt-r7dqm-oadVFC4nG_KAQdA4aB_ap55qOiI-hSJGE/s1600/doc+Type.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="77" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMuyHL58d_IHi7Bm5eZWAuYbiixljzI-a7O2AJD68UkTgbKYdKssYBME0g1lYOBBv_TvFGZ1wjOpXX5eFdSXrjvbbVs7Ysv9mv5Gt-r7dqm-oadVFC4nG_KAQdA4aB_ap55qOiI-hSJGE/s320/doc+Type.png" width="320" /></a></div>
Pay attention that Umbraco will change the alias of everything by removing the spaces and lower-casing the start character for the name.<br />
Click on add property and then fill its name, then select the type of the box that you want to show to your user in back office (not the viewer!). for instance you can select a rich text editor.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5gkBVyznbxsNBJEou4-exYa7pUs404JypNqSdRYF9i4EH7R5UoUvWHJI_Z48OWds0P4hp1c1mpg2ecgc_FOKFmBfYik9otLwMBDo8MaFTJWYi3Csux7x2Ir7xAzFpuAhf9l1KWpG5H6Y/s1600/field.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5gkBVyznbxsNBJEou4-exYa7pUs404JypNqSdRYF9i4EH7R5UoUvWHJI_Z48OWds0P4hp1c1mpg2ecgc_FOKFmBfYik9otLwMBDo8MaFTJWYi3Csux7x2Ir7xAzFpuAhf9l1KWpG5H6Y/s320/field.png" width="216" /></a></div>
This will let the user to put some text with good rich text tools (tiny MCE to be more specific). you can select options and then save the form.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuZc8oS0kb6Lamp7VL0XyLYywWwdyqEMWLSUqh7e39ur2X-MnrJXToEaAVKT8LnnDZtPftIdtuKqb_KZj64gk8VOeXNOws8_itHFlsCpJYa19c5KYTYSfYCZKEV_FDEuDiDg_B7kHZ-3s/s1600/field+end.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="104" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuZc8oS0kb6Lamp7VL0XyLYywWwdyqEMWLSUqh7e39ur2X-MnrJXToEaAVKT8LnnDZtPftIdtuKqb_KZj64gk8VOeXNOws8_itHFlsCpJYa19c5KYTYSfYCZKEV_FDEuDiDg_B7kHZ-3s/s320/field+end.png" width="320" /></a></div>
<br />
<b><span style="font-size: large;">Editing the view </span></b><br />
Open your templates and find the template with the same name. (if you cannot see it, right click on the templates and click on reload).<br />
<br />
This is your Razor View. You can do what ever you want in this view. You even don't need Visual studio to create/edit templates.<br />
<br />
You have different option to working with views. One of them is working with "dynamic" data type in C#. Write this code inside your view and you will be fine:<br />
<br />
<pre class="brush: csharp">@using Umbraco.Web
@using Umbraco.Web.Mvc
@inherits UmbracoTemplatePage
@{
Layout = null;
}
< h1 >@(CurrentPage.YourFieldName != null ? CurrentPage.YourFieldName: "")< / h1 >
</pre>
Easy right?<br />
There is also one other way which is working with properties:<br />
<pre class="brush: csharp">@using Umbraco.Web
@using Umbraco.Web.Mvc
@inherits UmbracoViewPage
@{
Layout = null;
}
< h1 > @(Model.HasValue("YourFieldName") ? Model.GetPropertyValue<string>("YourFieldName") : "")</ h1 >
</string></pre>
<br />
Both codes work fine. and since there is no compilation, there is nothing that important to differentiate.<br />
In later posts, I will show you how to work with strongly typed models inside Visual Studio (view/controller/services) but for now, set up your first page this way so you can see a sample page in Umbraco.<br />
<br />
For additional data, you can take a look at this post by <span style="background-color: #fefefe; color: #444444; font-family: , "georgia" , serif; font-size: 14px; line-height: 22.4px; text-align: right;">Dave Woestenborghs</span>:<br />
<a href="http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/">http://24days.in/umbraco/2015/strongly-typed-vs-dynamic-content-access/</a><br />
<br />
<b><span style="font-size: large;">Adding page to your site</span></b><br />
Go to your content tab right click on "content" and click create to create a new page. Select your type and click create. Now give your page a title, and fill your field, then click save.<br />
Now go to your base address to see your page.<br />
Congratulations, you've just created your first Umbraco site.<br />
<br />
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com1tag:blogger.com,1999:blog-9132129770667485834.post-40849896315268426202016-06-08T08:55:00.001-07:002016-06-09T01:06:31.560-07:00Relational Database Design:Simple rules for creating primary key<span style="font-size: large;"><b>Introduction</b></span><br />
<br />
Some years ago, I had some discussions with one of my friends about using defining the primary key. In the old days, as a software developer you had to implement your database first so most people though about how does the database works and how they can implement their solution in a suitable way.<br />
In these days, developers use ORMs most of the time which is very good, but at the same time, they start to ignore how their code will implement inside the DB. So it is important to consider how your data will be translated by ORM and what will you have inside your DB afterwards.<br />
<br />
<br />
<span style="font-size: large;"><b>Some Rules </b></span><br />
Well I think most people these rules, but there is no harm in mentioning them.<br />
<br />
<span style="background-color: white; color: #242729; font-family: "arial" , "helvetica neue" , "helvetica" , sans-serif; line-height: 19.5px;"><b><span style="font-size: large;">Primary keys should never change</span></b></span><br />
<br />
Your RDBMS, uses keys to manage tables, sort them, find them and make relation between them and the most important key obviously is the primary key. If you ever try to change the value of the primary key, it will affect other related tables.<br />
<br />
<b><span style="font-size: large;">You cannot use a natural key or a key form other system</span></b><br />
<br />
It is possible for natural keys to change, so you are obviously violation the first rule. You might say, oh someones ID will not change. But it is possible for the government the change the system of producing the ids then you have to change a lot of stuff.<br />
<br />
<b><span style="font-size: large;">They cannot have any formula</span></b><br />
<br />
It is also a violation of rule 1, since you may need to change the formula in the feature.<br />
<br />
<b><span style="font-size: large;">The uniqueness has to be easy to maintain</span></b><br />
<br />
Your RDBMS will prevent you from putting a duplicate inside your primary key, so if you are generating your key with a method that can create duplicates, you will have lots of problems that you cannot fix easily.<br />
<br />
<span style="font-size: large;"><b>Use short but suitable key type</b></span><br />
<br />
All RDBMS' use B+ threes as they index structure. They need to put your keys inside a table and fetch them so if you use a big key, your RDBMS can put less items inside a page and therefore, it has to access the disc more times which is the bottle neck of every business application.<br />
<br />
In SQL Server, number of index rows in each page can be calculated using this formula:<br />
<strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em>Index_Rows_Per_Page</em></strong><span style="color: #2a2a2a; font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: 13px; line-height: 18px;"> = 8096 / (</span><strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em>Index_Row_Size</em></strong><span style="color: #2a2a2a; font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: 13px; line-height: 18px;"> + 2)</span><br />
<br />
Which and size of each row equals:<br />
<strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em><br /></em></strong>
<strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em>Index_Row_Size</em></strong><span style="color: #2a2a2a; font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: 13px; line-height: 18px;"> = </span><strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em>Fixed_Key_Size</em></strong><span style="color: #2a2a2a; font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: 13px; line-height: 18px;"> + </span><strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em>Variable_Key_Size</em></strong><span style="color: #2a2a2a; font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: 13px; line-height: 18px;"> + </span><strong style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;"><em>Index_Null_Bitmap</em></strong><span style="color: #2a2a2a; font-family: "segoe ui" , "lucida grande" , "verdana" , "arial" , "helvetica" , sans-serif; font-size: 13px; line-height: 18px;"> + 1 (for row header overhead of an index row) + 6 (for the child page ID pointer)</span><br />
<br />
Considering the above, size of index row for int is<br />
int (4 bytes): 4+3+1+6=14<br />
Which means you can put <b>506 rows </b>inside a page<br />
<br />
<br />
<b style="font-size: x-large;">What are choises</b><br />
<br />
Considering the above, I will start with the worst one!<br />
<br />
<b><span style="font-size: large;">Never use (n)char or (n)varchar!</span></b><br />
<br />
If you are using (n)char or (n)varchar for your key, I am almost sure that you are violating of all rules above, since no one will store a string key generated by his system :)<br />
You will also need to worry about upper and lower case and the size of the key is also obviously big!<br />
<br />
For a varchar(50) you have: (2+1+50)+3+6+1 = 63<br />
Which means you have only <b>124 </b>keys inside a page which is awful<br />
<br />
Even for a varchar(20) you have: (2+1+20)+3+6+1 = 33<br />
Which means you have only <b>231 </b>keys inside a page which is still awful<br />
<div>
<br /></div>
<div>
And also, when you are creating your key, you will be vulnerable to concurrent requests. Like when 2 threads ask for a new key inside your application </div>
<br />
<br />
<b><span style="font-size: large;">Less than 1% of the times use GUID</span></b><br />
<br />
GUIDs are good data structure that can help you make sure that your key is unique. But at the same time, they are very big and they cannot be stored as a cluster index because there is no order in generating them.<br />
The good fact about them is that they are easy to move because there would be no conflict. Also, some times, you have to create the key inside a code, then it is of course better to use a GUID to reduce the chance of generating the same key, but I would say, try avoiding them as you can.<br />
For a GUID you have: (2+1+16)+3+6+1 = 29<br />
<br />
Which means you have only <b>261 </b>keys inside a page which is still bad<br />
<br />
<br />
<b><span style="font-size: large;">99% percent of the times use int with identity </span></b><br />
<br />
Int with the option of identity will help you to keep everything simple. It is very small and will take not much space. Use it with identity so you can make sure that the code will not generate a duplicate because of concurrent process. And it can also contain more than 2 billion different keys which is enough for most business systems.<br />
<br />
<b><span style="font-size: large;">Don't use small int or tiny int</span></b><br />
Tiny int and small int are too small but their size doesn't have that much effect in comparison with integer.<br />
<br />
For smallint (2 bytes): 2+3+1+6=12<br />
which means you can put <b>578 </b>rows inside a page which is 14% improvement but it can contain only 32,000 different values which is not that much<br />
<div>
<br />
For tiny int(1 bytes): 1+3+1+6=11<br />
which means you can put <b>622 </b>rows inside a page which seems to be 7% improvement but since it can contain only 256 values :| you cannot use the other 366! :) </div>
<div>
<br /></div>
<b><span style="font-size: large;">Less than 1% of the times use Bigint</span></b><br />
Ok! In very special projects, you might have a table that can contain more than 2 Billion rows! Like you are working for Amazon :) Then use bigint which I don't think happens for most developers in their professional life time :)<br />
<br />
<span style="font-size: large;"><b>References:</b></span><br />
Please find the formula for calculating size of rows, etc <a href="https://msdn.microsoft.com/en-us/library/ms190620.aspx" target="_blank">here in MSDN</a><br />
And for size of variables for to <a href="https://msdn.microsoft.com/en-us/library/ms187745.aspx" target="_blank">this page also in MSDN</a>Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com1tag:blogger.com,1999:blog-9132129770667485834.post-65999102103801099512016-06-06T00:48:00.000-07:002016-06-06T00:48:09.381-07:00EpiServer for beginners: How to add custom fields to Order (eCommerce) programatically<span style="font-size: large;"><b>Introduction</b></span><br />
<br />
Some times ago, I had <a href="http://pilpag.blogspot.dk/2016/03/episerver-for-beginners-how-to-add.html" target="_blank">a post about adding a custom field to eCommerce</a> from the user interface. That post got very popular and some folks like <a href="https://www.blogger.com/profile/17836903845668223475" rel="nofollow" style="background-color: white; color: #888888; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 12px; font-weight: bold; line-height: 16.8px; text-decoration: none;">Khurram Khan</a> and <a href="https://www.blogger.com/profile/04122782113369262447" rel="nofollow" style="background-color: white; color: #888888; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 12px; font-weight: bold; line-height: 16.8px; text-decoration: none;">Steve C.</a> mentioned that it is possible to add fields to eCommerce pragmatically. So in this post I will describe how to do it:<br />
<br />
<span style="font-size: large;"><b>Steps</b></span><br />
1- Create an initialization class<br />
<br />
Create a class, inherit from IInitializableModule, add InitializableModule and ModuleDependency attribute to your class and you are almost there.<br />
<br />
<pre class="brush: csharp"> [InitializableModule]
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class Initialization : IInitializableModule
</pre>
<br />
* You will need to add "EPiServer.Commerce.Initialization" to have InitializationModule, "EPiServer.Framework" to have InitializableModuleAttribute and "Mediachase.MetaDataPlus.Configurator" to have MetaField methods but of course VS will add them for you when you write the names correctly<br />
<br />
<br />
<div>
2- Create the constructor and get the context</div>
<div>
<pre class="brush: csharp"> public void Initialize(InitializationEngine context)
{</pre>
</div>
<div>
var mdContext = CatalogContext.MetaDataContext;</div>
<div>
<br /></div>
<div>
</div>
3- Use MetaField.Load to load your field from EPiServer.
<br />
<pre class="brush: csharp"> MetaField.Load(mdContext, name)
</pre>
<br />
4- If the result was empty, create the field using MetaField.Create<br />
The structure of the method is like this:<br />
<br />
<pre class="brush: csharp">MetaField Create(MetaDataContext context, string metaNamespace, string name, string friendlyName, string description, MetaDataType dataType, int length, bool allowNulls, bool multiLanguageValue, bool allowSearch, bool isEncrypted);
</pre>
<br />
* just to mention, length is the size of your data, so for example bool is 1, or DateTime is 8<br />
<br />
5- Load the class that you want to add the field to it using MetaClass.Load<br />
<pre class="brush: csharp"> var mtClass = MetaClass.Load(mdContext, metaClassName);
</pre>
<br />
6- Check if the meta field already exists in the meta class by checking its fields<br />
<pre class="brush: csharp"> cls.MetaFields.Contains(field);
</pre>
<br />
7- If the meta class doesn't have the class, add it using AddField<br />
<pre class="brush: csharp">mtClass.AddField(field);
</pre>
<br />
8- Smile :)<br />
<br />
--------<br />
It is very good idea to have simpler methods for adding fields and joining them to the meta class.<br />
<br />
<pre class="brush: csharp"> private MetaField GetOrCreateMetaField(MetaDataContext mdContext, string metaDataNamespace, string name, MetaDataType type, int length, bool allowNulls, bool cultureSpecific)
{
var f = MetaField.Load(mdContext, name) ??
MetaField.Create(mdContext, metaDataNamespace, name, name, string.Empty, type, length, allowNulls, cultureSpecific, false, false);
return f;
}
private void JoinField(MetaDataContext mdContext, MetaField field, string metaClassName)
{
var mtClass = MetaClass.Load(mdContext, metaClassName);
if (MetaFieldIsNotConnected(field, mtClass ))
{
cls.AddField(field);
}
}
</pre>
* And just to say: it is a good practice to have your strings inside enum classes. If you have a project, but you don't have any place for your enums and constants, you have to reconsider some of the stuff in your code :)<br />
<br />
The whole code look like this:<br />
<br />
<pre class="brush: csharp"> [InitializableModule]
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class Initialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
MetaDataContext mdContext = CatalogContext.MetaDataContext;
var myField = GetOrCreateMetaField(mdContext, Constants.Metadata.Namespace.Order,
Extensions.PurchaseOrderExtensions.myFieldName, MetaDataType.DateTime, 8, true, false);
JoinField(mdContext, myField, Constants.Metadata.OrderForm.ClassName);
}
private MetaField GetOrCreateMetaField(MetaDataContext mdContext, string metaDataNamespace, string name, MetaDataType type, int length, bool allowNulls, bool cultureSpecific)
{
var f = MetaField.Load(mdContext, name) ??
MetaField.Create(mdContext, metaDataNamespace, name, name, string.Empty, type, length, allowNulls, cultureSpecific, false, false);
return f;
}
private void JoinField(MetaDataContext mdContext, MetaField field, string metaClassName)
{
var mtClass = MetaClass.Load(mdContext, metaClassName);
if (MetaFieldIsNotConnected(field, mtClass ))
{
cls.AddField(field);
}
}
private static bool MetaFieldIsNotConnected(MetaField field, MetaClass mtClass )
{
return mtClass != null && !cls.MetaFields.Contains(field);
}
}
</pre>
<b><span style="font-size: large;">A Sample in a project</span></b><br />
You can look at Steves <strong itemprop="name"><a data-pjax="#js-repo-pjax-container" href="https://github.com/BVNetwork/CommerceStarterKit" style="box-sizing: border-box; color: #4078c0; font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 26px; text-decoration: none;">CommerceStarterKit</a><span style="color: #666666; font-family: "helvetica" , "arial" , "nimbussansl" , "liberationsans" , "freesans" , "clean" , sans-serif , "apple color emoji" , "segoe ui emoji" , "segoe ui symbol";"><span style="box-sizing: border-box; line-height: 26px;"> </span></span></strong><span style="box-sizing: border-box;">and to be more specific, <a href="https://github.com/BVNetwork/CommerceStarterKit/blob/master/src/web/Business/Initialization/MetadataInitialization.cs" target="_blank">this </a>page :)</span><strong itemprop="name"><span style="color: #666666; font-family: "helvetica" , "arial" , "nimbussansl" , "liberationsans" , "freesans" , "clean" , sans-serif , "apple color emoji" , "segoe ui emoji" , "segoe ui symbol";"><span style="box-sizing: border-box; line-height: 26px;"> </span></span></strong><br />
<br />
<span style="background-color: white; font-family: "arial" , sans-serif; white-space: nowrap;"><b><span style="font-size: large;">Acknowledgment</span></b></span><br />
My gratitude to <span style="background-color: white; color: #333333; font-family: "helvetica" , "arial" , "nimbussansl" , "liberationsans" , "freesans" , "clean" , sans-serif , "apple color emoji" , "segoe ui emoji" , "segoe ui symbol"; font-weight: bold; line-height: 30px;">Steve Celius</span> for sharing his code with us.Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com4tag:blogger.com,1999:blog-9132129770667485834.post-57630206281926030112016-05-28T03:25:00.001-07:002016-06-06T08:01:52.368-07:00Programming tips: Entity Framework (any ORM) is NOT the GOD of Data! You need to know how to work with it<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtV6vrvKqH2qBpodNlMjHCoRRiWbuvOxKwrN0y0Z7LYVPd9ti5yzJapyukEGCbBzhWmjzWOd6XFTAT87N5rWlr2jI8k8I0QvD_0-MpMhib6AIgUMmFe3qAjDe3SyuBJuN1br-96wxaUjk/s1600/ORM+no+God.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtV6vrvKqH2qBpodNlMjHCoRRiWbuvOxKwrN0y0Z7LYVPd9ti5yzJapyukEGCbBzhWmjzWOd6XFTAT87N5rWlr2jI8k8I0QvD_0-MpMhib6AIgUMmFe3qAjDe3SyuBJuN1br-96wxaUjk/s320/ORM+no+God.jpg" width="320" /></a></div>
<span style="font-size: large;"><b>Introduction</b></span><br />
<br />
In my professional life, I've worked with different ORMs and of course the best ones were Hibernate and Entity Framework. They will save almost half of the time that you had to spend for your software by handling the requests to DB so you just need to know how to work with objects instead of relational data. However, they are no gods! They will do the same thing that you are telling them, They cannot work miracles because they don't know what is your intention! They are simply some software systems!<br />
<br />
<span style="font-size: large;"><b>The problem</b></span><br />
<br />
A simple question can result to the answer. Take an individual who knows Object Oriented and give him this classes.<br />
<br />
<div class="csharpcode">
Code:<br />
<pre class="brush: csharp"><span class="type">
class A
{
public string Status{get;set;}
public List<B> Bs{get;set;}
}
class B
{
public string Status{get;set;}
public List<C> Cs{get;set;}
}
class C
{
public string Status{get;set;}
public string Name{get;set;}
}
</span></pre>
</div>
Now ask him to give you name of cs that are in status 'BLBlah' he can find in B with Status 'Blah' and are in As with Status 'BlahBlah'. You will end up with a code like this:<br />
<br />
<div class="csharpcode">
Code:<br />
<pre class="brush: csharp"><span class="type">
var results = new List<string>();
Var selectedAs = context.As.Where(a=> a.Status== "BlahBlah" );
foreach(a in selectedAs)
{
var selectedBs = a.Bs.Where(b=>b.Status=="Blah");
foreach(b in selectedBs)
{
var selectedNames = b.Cs.Where(c=>c.Status=="BLBlah").Select(c=>c.Name).ToList();
results.AddRange(selectedNames);
}
}
return results;
</span></pre>
</div>
Pretty straight forward, huh? He rocks! and the ORM rocks! Right?!<br />
Well he just added a lot of overhead to your DB!<br />
<br />
<span style="font-size: large;"><b>What is wrong with this code?</b></span><br />
<br />
The way you've asked your query! Lets say there are 100 As with wanted status and for each of them you have 100 Bs with wanted status.<br />
You've asked your ORM to find those 100 A, then for each of them you've asked it to find Bs and then for each one find Cs.<br />
It is completely fine if you are working with your memory, but this code means :<br />
<b>1 call for As + (100 calls for Bs * 100 Call for Cs * (1 projection + addrange)) = 100001</b><br />
<br />
So you've sent 10,001 requests to DB for a simple 3 layer select! How fast can it be?!!!<br />
<br />
<span style="font-size: large;"><b>Lets See another Code</b></span><br />
<br />
So now you might say that it is because of the foreachs I wrote, but that is not the case.<br />
Lets say I want to convert the structure above to this one and then use it somewhere.<br />
<br />
<div class="csharpcode" >
Code:<br />
<pre class="brush: csharp" ><span class="type">
Calss ConvertedA
{
public string Status{get;set;}
public List<string> BStatuses{get;set;}
<div>
public List<string> CNames{get;set;}</div>
<div>
</div>
}
</span></pre>
</div>
With simple Object Oriented view you will probably end up with this code (With no foreach):
<br />
<div class="csharpcode">
Code:<br />
<pre class="brush: csharp"><span class="type">
List<ConvertedA> GetConvertedList()
{
var As= context.As;
return context.As.Select(a=> new ConvertedA()
{
Status = a.Status,
BStatuses = a.Bs.Select(b=>b.Status).ToList()
CNames= a.Bs.SelectMany(b=>b.Cs).Select(c=>c.Name)
};
}
</span></pre>
</div>
<br />
OMG! What a wonderful query! right?! So Simple! But again, you are sending lots of requests to DB! why?<br />
1 selectAs+ 100 Select Bs+ 100Bs*100Cs = 10,101 requests!<br />
<br />
<span style="font-size: large;"><b>The Solution</b></span><br />
<br />
There are 2 solutions to this problem. One is from the view of Software Architect, and the other from the view of programmer.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQydAwka6NhJp4Kh7hMzWJ1LaES5A0gRAd2H3EHOCuOCtoyB-7s8U-8XN1kejBvPg5GVUKFYcx5cUdaGbuyQM3pBVp5JclHsy939qyMob-HWC9ieTyMLLzf8ZKRfoDEGFJNrQjFka_p8w/s1600/Cartoons_Minions_architect_051618_.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="173" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQydAwka6NhJp4Kh7hMzWJ1LaES5A0gRAd2H3EHOCuOCtoyB-7s8U-8XN1kejBvPg5GVUKFYcx5cUdaGbuyQM3pBVp5JclHsy939qyMob-HWC9ieTyMLLzf8ZKRfoDEGFJNrQjFka_p8w/s320/Cartoons_Minions_architect_051618_.jpg" width="320" /></a></div>
<br />
<span style="font-size: large;"><b><br /></b></span>
<span style="font-size: large;"><b>The programmer</b></span><br />
<br />
<b>Write the best query</b><br />
As <b>Mahdi Hasheminejad </b>in the comments, there are many cases that you can select the correct data with one query. It is pretty useful and of course is the best way to solve the problem. As he mentioned, the query can be written like this:<br />
<br />
var results = context.As<br />
.Where(a => a.Status == "BlahBlah").SelectMany(a => a.Bs)<br />
.Where(b => b.Status == "Blah").SelectMany(b => b.Cs)<br />
.Where(c => c.Status == "BLBlah");<br />
<br />
And the result will be translated to this query:<br />
SELECT<br />
[Extent3].[Status] AS [Status],<br />
[Extent3].[Name] AS [Name],<br />
FROM [A] AS [Extent1]<br />
INNER JOIN [B] AS [Extent2] ON ...<br />
INNER JOIN [C] AS [Extent3] ON ...<br />
WHERE (N'BlahBlah' = [Extent1].[Status]) AND (N'Blah' = [Extent2].[Status]) AND (N'BLBlah' = [Extent3].[Status])<br />
<br />
<b>Load needed data in memory</b><br />
If you cannot handle your request with a good query, load your data first! A good example for this case is when you need to compare something with the result of something out of your DB, like when you need to call a service.<br />
Like for the first example, you can say:<br />
var Cs = context.Cs.Where(c=>c.Stauts="Blah").ToList();<br />
Var Bs = context.Bs..Where(b=>b.Status=="Blah").ToList();<br />
<br />
Now use these 2 lists inside your foreach and compare them with their Ids.<br />
<br />
<br />
<span style="font-size: large;"><b>The Architect</b></span><br />
<br />
ORMs simply map tables to related objects in memory. But, there are 2 ways of working with relations. Lazy loading (which is the default in most ORMS) and Eager Loading.<br />
Lazy loading simply means that ORM will wait for you to ask for something, and then it will load the data. For instance :<br />
var a = context.As.First();<br />
This will only load 1 A object from the memory and nothing more.<br />
Now if you write:<br />
Var bs = a.Bs.ToList()<br />
Your ORM will send another request to fetch the Bs.<br />
This is exactly what most codes needs. But in some cases, we know that the a is not usable without their Bs. So the architect can decide to use Eager loading for that relation. So when you say<br />
var a = context.As.First();<br />
<br />
Your ORM will retries your A and all Bs that are related to it.<br />
<br />
*The Eager loading, is not a good solution for 90% of the times. It depends to nature of your data! So don't use it perfunctory.<br />
<br />
<span style="font-size: large;"><b><br /></b></span>
<br />
<br />
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com3tag:blogger.com,1999:blog-9132129770667485834.post-27971480379560214042016-05-27T06:30:00.002-07:002016-05-29T01:47:29.672-07:00Software Architecture Tips- Don't put logs in your production DB<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd7Ja8dHPbXavMsIrC_wn8Lr3ebPPXS6TO-6PjiT37LtZ4_E39UExykLUdwcKc2VMbZUISLP9iJ1K1ANhmfGeuWg-cjSmShSaHCoR3cAMg_3RGky7CADcEuEOUVYCfCKpuEno2Il05ACE/s1600/No-Log-In+DB.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="174" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd7Ja8dHPbXavMsIrC_wn8Lr3ebPPXS6TO-6PjiT37LtZ4_E39UExykLUdwcKc2VMbZUISLP9iJ1K1ANhmfGeuWg-cjSmShSaHCoR3cAMg_3RGky7CADcEuEOUVYCfCKpuEno2Il05ACE/s320/No-Log-In+DB.png" width="320" /></a></div>
<br />
Sometimes ago, I had some discussions with one of my friends regarding having the logs inside DB.<br />
While it might be interesting for many people, it is really a bad idea.<br />
<br />
<span style="font-size: large;"><b>Why people decide to have their logs on DB</b></span><br />
<br />
First thing, first :) we have to see what is good about having your logs inside a DB. Most people claim that when you have multiple servers (like web-servers) it is hard to collect your logs and combine them in order to understand what goes wrong.<br />
That is a true point, but there are many other ways to do that, without affecting your important resources.<br />
<br />
<span style="font-size: large;"><b>What is the disadvantage?</b></span><br />
<br />
* First, you are sacrificing the most valuable resource in your system to keep some stupid logs to use in the future! You just need to have them somewhere for future reference! That is all! No realtime access, no need to have indexing or etc.<br />
<br />
* Secondly, you might loose your logs, when the network goes down, or the DB goes down, you will not have a clue about what had happened in your code.<br />
<br />
* Then: You will stop logging the other important parts in your code, since you will think of the resources you are using. You will loose all Debugs and Info's because if you start logging them, your DB will struggle to return a simple select to you! So you will ignore many important logs that you will need in the future.<br />
<br />
<b><span style="font-size: large;">What is the log in the view of Software Architecture</span></b><br />
<br />
Logs are simply some data that have to be managed separately. They are not there to meet your systems functionalities. The only reason for having them, is to help you find out what is wrong with the system and fix it ASAP.<br />
<br />
<span style="font-size: large;"><b>What to do then?</b></span><br />
<br />
First, your logging system has to be implemented in a way that you can change the behavior easily. If you want to add debug logs or remove them you have to be able to do it. The thread that is handling your logs has to be different than the ones which are handling your systems process. No critical resources has to get busy because of logging.<br />
<br />
<b><span style="font-size: large;">But it is takes a lot of time!</span></b><br />
<br />
There are lots of different logging libraries. One of the best ones are <a href="https://logging.apache.org/log4net/" target="_blank">Log4net</a> for .net applications. It has been implemented by Apache and it is very easy to use.<br />
It has an xml file that you can use to say what to do with a log, and what shall be the format of the output, etc. You can also say that I want my output to be handled in several different ways, and it has a separate thread so it won't affect your system.<br />
<br />
<b><span style="font-size: large;">Where shall I put my logs then?</span></b><br />
<br />
Of course the first place to put your logs, is on the disc. It is available all the time (if not, your server will go down so you have no logs :) ), it is not a valuable resource and it is almost free since you are on the web-server. I suggest to have a file for all of your logs and another one only for Errors and Fatals, so you can see the errors easily.<br />
<br />
<span style="font-size: large;"><b>But I can't check my logs everyday specially since I have several servers</b></span><br />
<br />
As I mentioned, it is not a problem of your system. The log manager has to handle it and you can do it easily by confining your logger. There are many solutions for collecting logs. <a href="http://getsentry.com/" target="_blank">Sentry</a> is one of the simplest. You can tell your logger to push all errors to your sentry account and then check them in a managed third party web-application easily. There are also some other systems that check your log files and update their status based on those files.<br />
<br />
So if you have several applications that you have to take care of, you can see all of the process in a third party application somewhere else and you've just used 1 thread of your system, your web-applications disc and a small portion of your network.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3HY9Dqyy_0e-tH4fYZu1S8fov2ag-F7ry1zdN2h_DvRqjTBHDSxloUZczsknU1DN8Hqq33HvysksK5twTr27XCAoF8aaBCAuQuY9lxAuIm8LuhEsIRiR1ZIuFt53KMB3qu43GnLIhN9o/s1600/Logging-Arch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="171" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3HY9Dqyy_0e-tH4fYZu1S8fov2ag-F7ry1zdN2h_DvRqjTBHDSxloUZczsknU1DN8Hqq33HvysksK5twTr27XCAoF8aaBCAuQuY9lxAuIm8LuhEsIRiR1ZIuFt53KMB3qu43GnLIhN9o/s320/Logging-Arch.png" width="320" /></a></div>
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com1tag:blogger.com,1999:blog-9132129770667485834.post-59721751058320562762016-05-26T06:45:00.001-07:002016-05-26T06:51:30.116-07:00Programming Tips: Don't mix 2 tasks together<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitxciG4OOsr45ST-HtrB-4P1iLG9SPRjFxDmOHJCsLWvEX0k5VBSSgDyoXQrz2LBR4VQKgo6DYdxz9wcQBxUrO1SaNSoWG4atBPA2YqvN9Xc8lDJRv9T-PL4UmwpeZwNy_O0xW0H0u_VI/s1600/mix.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitxciG4OOsr45ST-HtrB-4P1iLG9SPRjFxDmOHJCsLWvEX0k5VBSSgDyoXQrz2LBR4VQKgo6DYdxz9wcQBxUrO1SaNSoWG4atBPA2YqvN9Xc8lDJRv9T-PL4UmwpeZwNy_O0xW0H0u_VI/s1600/mix.png" /></a></div>
<br />
In my professional life, I've seen lots of people with different coding styles, but one of the most important issues that most programmers have is due to the fact that they mix different tasks together.<br />
<br />
<span style="font-size: large;"><b>Rule of 30</b></span><br />
<br />
You've probably heard of rule of 30 in clean code, but did you ever thought why a simple rule like this is so important?<br />
The reason is simple: To make you create simpler methods.<br />
So if you have a method that will do 10 things together, you will be forced to write 10 different methods and then call them<br />
<br />
<b><span style="font-size: large;">Why some people avoid it</span></b><br />
<br />
Well, in my opinion 30 lines is enough for implementing a singe task, most of the times. And I reserve 1% for something that is an exception, but what about the other times?!<br />
In my opinion, most of the times it is hard for people decide about separating different parts of a big task to several smaller tasks so they try to solve the whole problem in a big and ugly method.<br />
<br />
<b><span style="font-size: large;">Example</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
Any normal method that you write in daily basis can be a simple example for this mater. For instance, reading data from some text and filling your tables in DB. Very easy, right?<br />
<br />
If you don't divide your big task, you will have a big method for doing everything and then you probably try to read every line and for each line you will try to save data into your DB. Right?<br />
It is ugly code and I didn't even started! :)<br />
OK, hopefully you have a DB with good structure, so you need to put your stuff in tables that they have some items it-selves.<br />
....And most of the times your text data is not normalized data ( you wish! :) )<br />
So you will start to reading data, line by line. storing common data into parent tables the first time and then ignoring them next times.<br />
<br />
<b>You see where it is going! right?! UGLY!UGLY! LAKH!</b><br />
<br />
<b>What should you do?!</b><br />
<h2 style="background-color: white; border-bottom-color: transparent; border-bottom-style: solid; border-bottom-width: 1px; color: #444444; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14px; font-stretch: normal; margin: 0px -15px; padding: 0.6em 15px 0.5em; position: relative;">
<span style="font-weight: normal;">You have a task to read data from text and store in in DB right?! So read the data first into structured objects (like DTO) and then save them into DB in another method. You have complex objects?! easy! create a method for reading each one and call them inside the parent!</span></h2>
<div>
<span style="font-weight: normal;"><br /></span></div>
<div>
<b>What is the benefits? </b></div>
<div>
* It is easy to understand what you did. So easy to maintain and debug</div>
<div>
* You have separated methods based on your functionalities. So you can reuse your code. </div>
<div>
* You managed your situation on each method based on what it has to do. So your code handles the situation better</div>
Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com0tag:blogger.com,1999:blog-9132129770667485834.post-15368209815119391512016-04-29T03:07:00.000-07:002016-04-29T03:44:57.555-07:00String or binary data would be truncated. EPiServer<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhthb582YO01IaBrWFrf-O3jVDFmnKxMSAlJL84DEG7EflY7KaGfhjjDY3O5IKPwOKYUsByt80YuXALRyk_ZqUYtJ_UK6PMqoLEZJPXxqq-sFDJq1ASYuHhS0f0lhu6qrIA831cWKtJyEY/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="129" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhthb582YO01IaBrWFrf-O3jVDFmnKxMSAlJL84DEG7EflY7KaGfhjjDY3O5IKPwOKYUsByt80YuXALRyk_ZqUYtJ_UK6PMqoLEZJPXxqq-sFDJq1ASYuHhS0f0lhu6qrIA831cWKtJyEY/s640/Untitled.png" width="640" /></a></div>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;">Introduction</span></b><br />
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:<br />
<b><span style="font-size: large;">String or binary data would be truncated</span></b><br />
<br />
I know what you are thinking:<br />
"Yup! OK, Someone used a name longer than 50 char..."<br />
<br />
But that was not the story!<br />
<br />
<b><span style="font-size: large;">How did I check</span></b><br />
<br />
Fortunately, we were at the end of sprint, so I could check all new properties very fast but there was nothing wrong. I've checked my DB with a query like the one that I used for finding my string in <a href="http://pilpag.blogspot.dk/2016/04/search-for-string-in-all-tables-rows.html" target="_blank">here</a> and checked for strings with len>50. And I've shocked since there was nothing wrong.<br />
<br />
Then I've asked my good friends in EPiServer to <a href="http://world.episerver.com/forum/developer-forum/Developer-to-developer/Thread-Container/2016/4/-string-or-binary-data-would-be-truncated--the-statement-has-been-terminated/" target="_blank">help me</a>. <a href="http://world.episerver.com/System/Users-and-profiles/Community-Profile-Card/?userid=9b7dad33-b57b-e011-a4b8-0018717a8c82" style="background-color: white; border-bottom-style: none; color: #414bfa; font-family: 'Simplon Norm', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 22px; text-decoration: none;">Quan Mai</a><span style="background-color: white; color: #898b8b; font-family: "simplon norm" , "arial" , "helvetica" , sans-serif; font-size: 12px; line-height: 22px;"> </span>and <span style="background-color: white;"><a href="http://world.episerver.com/System/Users-and-profiles/Community-Profile-Card/?userid=87c90252-5047-dd11-93be-0018717a8c82" style="border-bottom-style: none; color: #414bfa; font-family: 'Simplon Norm', Arial, Helvetica, sans-serif; font-size: 12px; line-height: 22px; text-decoration: none;">Daniel Ovaska</a> </span>guided me how to find the cause of the problem.<br />
<br />
Faithfully, I had a back up from the last night so I could compare it with my working copy easily using "Visual Studio SQL server database comparison tool" that I've described in <a href="http://pilpag.blogspot.dk/2016/04/how-to-compare-2-sql-server-databases.html" target="_blank">here</a> :) and found the problem.<br />
<br />
<br />
<span style="font-size: large;"><b>The Problem</b></span><br />
<br />
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 :)<br />
<br />
Anyways, I've found the problem! Yayyyyy!<br />
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've found the properties of the other one inside my DB....<br />
<br />
Why?<br />
Well if you switch your working branch, it will change the web config, but what you don't keep your dlls inside your source control, right? So keep in mind to rebuild your code before browsing your site :)<br />
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com0tag:blogger.com,1999:blog-9132129770667485834.post-7440440252011596852016-04-29T03:06:00.002-07:002016-04-29T03:06:06.297-07:00How to compare 2 Sql Server Databases with VS 2015<b><span style="font-size: large;">Introduction</span></b><br />
<br />
There are some times that you need to check your DB, either the data or schema. Sometimes you have a back up and you want to see what has been added updated or removed from your data, like when you have an error that you cannot find the cause.<br />
Sometimes, you want to see if someone has changed the schema and you want to know what is the change.<br />
<br />
<span style="font-size: large;"><b>Solution </b></span><br />
It is an old problem right? But in the old days you had to pay lots of money to be able to do that.<br />
Take a look at <a href="http://www.red-gate.com/products/sql-development/sql-data-compare/" target="_blank">Red Gate SQL data compare</a> or <a href="http://www.sqlaccessories.com/sql-data-examiner/?gclid=Cj0KEQjwjIy5BRClh8m_9Zu64d8BEiQAtZsQfw93QhXAvvGDdSkhFCrF2WpCVg7TUGnUZqbceBIPlGwaAn9W8P8HAQ" target="_blank">SQL Data Examiner </a>. Yup you have to pay at least 300$ to do that. :|<br />
But the good news is that your Visual Studio has the ability to Do a lot of Data and Schema comparison which is free and more importantly it is inside our great tool Visual Studio. :)<br />
<br />
<b><span style="font-size: large;">How to do it?</span></b><br />
Inside Visual Studio 2015 (mine is professional) Go to Tools >SQL Server. you will see 2 options for comparing Data, or Schema.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvSWfl7ZX1115LNBLSWQHKYqzXB2RMfCoW0uMnmFRIvn2oqqlgXJJYhKhjXOG9vEvAQJpjpI39pZW5CWff7rYnaIzOtST71bczQ1VVIRwwbHbgzOEbcgcBWgT6nIGITxRKQUZEcwTyQm4/s1600/vs1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvSWfl7ZX1115LNBLSWQHKYqzXB2RMfCoW0uMnmFRIvn2oqqlgXJJYhKhjXOG9vEvAQJpjpI39pZW5CWff7rYnaIzOtST71bczQ1VVIRwwbHbgzOEbcgcBWgT6nIGITxRKQUZEcwTyQm4/s320/vs1.png" width="320" /></a></div>
<br />
<br />
Insert your connection Data, click compare and you are good to go :)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSKkjpVFfNOSdci5guZtEAZXBboOXt-UPU8sUPjGhFg8v6a7_XR1YoK48N51EQtQnLq4711n4h3LyYt9EQgnVsbwF33q2nkhqRq3yP8doDJM5CVzYMKrA7p5yvdSxnC-azzHAoT0hH9Xo/s1600/vs2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="140" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSKkjpVFfNOSdci5guZtEAZXBboOXt-UPU8sUPjGhFg8v6a7_XR1YoK48N51EQtQnLq4711n4h3LyYt9EQgnVsbwF33q2nkhqRq3yP8doDJM5CVzYMKrA7p5yvdSxnC-azzHAoT0hH9Xo/s320/vs2.png" width="320" /></a></div>
<br />Ashkanhttp://www.blogger.com/profile/02127447561740055366noreply@blogger.com17