<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>jebarson's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jebarson/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jebarson/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:11:29 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Benchmarking Index Fragmentation With Popular Sequential GUID Algorithms</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/benchmarking-index-fragmentation-with-popular-sequential-guid-algorithms</link>
      <pubDate>Tue, 16 Jan 2018 12:56:25 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/?p=485</guid>
      <description><![CDATA[In a multi-tenant data insert scenario, GUID is a great data type for primary key. Since it is...]]></description>
      <content:encoded><![CDATA[In a multi-tenant data insert scenario, GUID is a great data type for primary key. Since it is unique globally, you will not need to rely on any range or custom logic. However, if you extend these columns as index, you will end up with frequent index fragmentation and hence bad performance. In this post, I will be benchmarking index fragmentation with popular sequential Guid algorithms.

<strong>Option 1</strong> (GUID using NewGuid): In this option, we will create a GUID from the application and then insert the same into the table. We will use this as the base benchmark for the comparison. We are already aware of the fact that this option ends up in huge defragmentation. This option is no different from calling NewId() function at SQL.

<strong>Option 2</strong> (Sequential GUID using SQL’s NewSequentialId): In this option, we will let the SQL to create the sequential GUID using the inbuilt function.

<strong>Option 3</strong> (Sequential GUID based on UuidCreateSequential): In this option, we will write an algorithm which is equivalent to NewSequentialId. This will use the UuidCreateSequential; a COM system method. NewSequentialId also shares the same COM method. This algorithm is posted by David Browne (fellow MS employee) and his original post could be found at <a target="_blank" href="https://blogs.msdn.microsoft.com/dbrowne/2012/07/03/how-to-generate-sequential-guids-for-sql-server-in-net/" rel="noopener">https://blogs.msdn.microsoft.com/dbrowne/2012/07/03/how-to-generate-sequential-guids-for-sql-server-in-net/</a>

<strong>Option 4</strong> (GUID based on NHibernate’s GuidCombGenerator): In this option, we will use the algorithm NHibernate uses to generate a GUID for certain features. Many developers have claimed to use this algorithm to overcome the issue we are discussing. The source code for the same could be found at <a target="_blank" href="https://github.com/nhibernate/nhibernate-core/blob/3087d48640eb64f573c0011e9a9b1567afe6adde/src/NHibernate/Id/GuidCombGenerator.cs" rel="noopener">https://github.com/nhibernate/nhibernate-core/blob/3087d48640eb64f573c0011e9a9b1567afe6adde/src/NHibernate/Id/GuidCombGenerator.cs</a>

&nbsp;
<h3>Output</h3>
<span>There was latency of 220ms to the Azure data center from my machine.</span>
<table>
<thead>
<tr class="row-1 odd">
<th class="column-1"></th>
<th class="column-2">Option 1
(Guid using NewGuid)</th>
<th class="column-3">Option 2
(Sequential Guid using SQL’s NewSequentialId)</th>
<th class="column-4">Option 3
(Sequential Guid based on UuidCreateSequential)</th>
<th class="column-5">Option 4
(Guid based on NHibernate’s GuidCombGenerator)</th>
</tr>
</thead>
<tbody class="row-hover">
<tr class="row-2 even">
<td class="column-1">Duration</td>
<td class="column-2">346s</td>
<td class="column-3">300s</td>
<td class="column-4">343s</td>
<td class="column-5">359s</td>
</tr>
<tr class="row-3 odd">
<td class="column-1">Application Memory

&nbsp;</td>
<td class="column-2">22 – 23MB (No Leak)</td>
<td class="column-3">17 – 19MB (No Leak)</td>
<td class="column-4">21 – 23MB (No Leak)</td>
<td class="column-5">21 – 23MB (No Leak)</td>
</tr>
<tr class="row-4 even">
<td class="column-1">Application CPU (8 Core)

&nbsp;</td>
<td class="column-2">&lt; 1%</td>
<td class="column-3">&lt; 1%</td>
<td class="column-4">&lt; 2%</td>
<td class="column-5">&lt; 2%</td>
</tr>
<tr class="row-5 odd">
<td class="column-1">DTU Consumption (DTU / CPU / Data / Log)

&nbsp;</td>
<td class="column-2">62 / 44 / 0 / 62</td>
<td class="column-3">56 / 29 / 0 / 56</td>
<td class="column-4">47 / 42 / 0 / 47</td>
<td class="column-5">59 / 41 / 7 / 59</td>
</tr>
<tr class="row-6 even">
<td class="column-1">Pages (Clustered Index / Non-Clustered Index)

&nbsp;</td>
<td class="column-2">14335 / 13467</td>
<td class="column-3">9901 / 10527</td>
<td class="column-4">9901 / 10527</td>
<td class="column-5">15868 / 14994</td>
</tr>
<tr class="row-7 odd">
<td class="column-1">Page Density % (Clustered Index / Non-Clustered Index)

&nbsp;</td>
<td class="column-2">68.9 / 68.75</td>
<td class="column-3">99.8 / 99.73</td>
<td class="column-4">99.8 / 99.73</td>
<td class="column-5">66.16 / 65.89</td>
</tr>
<tr class="row-8 even">
<td class="column-1">Fragmentation % (Clustered Index / Non-Clustered Index)</td>
<td class="column-2">99.27 / 99.03</td>
<td class="column-3">1.87 / 0.76</td>
<td class="column-4">1.88 / 0.77</td>
<td class="column-5">91.66 / 91.49</td>
</tr>
</tbody>
</table>
&nbsp;

If you are interested in the complete benchmark process, code I have used and my suggestion, please visit my full article posted at <a href="https://microsoftprogrammers.jebarson.com/benchmarking-index-fragmentation-with-popular-sequential-guid-algorithms/">https://microsoftprogrammers.jebarson.com/benchmarking-index-fragmentation-with-popular-sequential-guid-algorithms/</a>]]></content:encoded>
    </item>
    <item>
      <title>Check If Your Processor Has AVX Instruction Support</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/check-if-your-processor-has-avx-instruction-support</link>
      <pubDate>Wed, 10 Jan 2018 08:00:08 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/?p=456</guid>
      <description><![CDATA[If you are trying to develop applications in Q# (Quantum Computing), then you would require support...]]></description>
      <content:encoded><![CDATA[If you are trying to develop applications in Q# (Quantum Computing), then you would require support of AVX instruction set in your processor. While Microsoft is working on removing this limitation as of today, it may take a while before the limitation is removed.

If your processor is shipped On or after Sandy Bridge (2011) era, the chances that the support is there. However, for you to be sure about that, you could download the tool from my blog to verify the same.

https://microsoftprogrammers.jebarson.com/q-quantum-computing-introduction/

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Writing an asynchronous RelayCommand implementing ICommand</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/writing-an-asynchronous-relaycommand-implementing-icommand</link>
      <pubDate>Wed, 26 Jul 2017 13:35:06 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/?p=445</guid>
      <description><![CDATA[Read the full article here

If you are familiar with MVVM, then you are already...]]></description>
      <content:encoded><![CDATA[<div id="main" class="clearfix">
<div class="inner-wrap">
<div id="primary">
<div id="content" class="clearfix"><article id="post-1104" class="post-1104 post type-post status-draft format-standard hentry category-net category-uwp category-wpf-2 tag-async tag-relay-command">
<div class="entry-content clearfix">

<a href="https://microsoftprogrammers.jebarson.com/writing-an-asynchronous-relaycommand-implementing-icommand/">Read the full article here</a>

If you are familiar with MVVM, then you are already familiar with relay commands. We use relay commands to map a method with the ICommand raised from a control. Below is the typical code snippet you may have seen a lot of time.

The class below is pretty simple; it accepts a method and allows you to associate it with a command. Whenever the command is invoked, it is relayed to the method we have passed on as “execute” param. It acts like a disconnected event, if I may say.
<div class="wp_syntax">
<table>
<tbody>
<tr>
<td class="code">
<pre class="csharp">    <span>public</span> <span>class</span> RelayCommand <span>:</span> ICommand
    <span>{</span>
        <span>private</span> <span>readonly</span> Action executedMethod<span>;</span>
        <span>private</span> <span>readonly</span> Func<span>&lt;</span>T, <span>bool</span><span>&gt;</span> canExecuteMethod<span>;</span>
 
        <span>public</span> <span>event</span> EventHandler CanExecuteChanged<span>;</span>
        <span>public</span> RelayCommand<span>(</span>Action execute<span>)</span> <span>:</span> <span>this</span><span>(</span>execute, <span>null</span><span>)</span> <span>{</span> <span>}</span>
 
        <span>public</span> RelayCommand<span>(</span>Action execute, Func<span>&lt;</span>T, <span>bool</span><span>&gt;</span> canExecute<span>)</span>
        <span>{</span>
            <span>this</span><span>.</span><span>executedMethod</span> <span>=</span> execute <span>??</span> <span>throw</span> <span>new</span> ArgumentNullException<span>(</span><span>"execute"</span><span>)</span><span>;</span>
            <span>this</span><span>.</span><span>canExecuteMethod</span> <span>=</span> canExecute<span>;</span>
        <span>}</span>
 
        <span>public</span> <span>bool</span> CanExecute<span>(</span><span>object</span> parameter<span>)</span> <span>=&gt;</span> <span>this</span><span>.</span><span>canExecuteMethod</span> <span>==</span> <span>null</span> <span>||</span> <span>this</span><span>.</span><span>canExecuteMethod</span><span>(</span><span>(</span>T<span>)</span>parameter<span>)</span><span>;</span>
        <span>public</span> <span>void</span> Execute<span>(</span><span>object</span> parameter<span>)</span> <span>=&gt;</span> <span>this</span><span>.</span><span>executedMethod</span><span>(</span><span>(</span>T<span>)</span>parameter<span>)</span><span>;</span>
        <span>public</span> <span>void</span> OnCanExecuteChanged<span>(</span><span>)</span> <span>=&gt;</span> CanExecuteChanged<span>?.</span><span>Invoke</span><span>(</span><span>this</span>, EventArgs<span>.</span><span>Empty</span><span>)</span><span>;</span>
    <span>}</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
Since Action deals with void functions, we cannot get the async methods working. So I resorted for Func instead of Action and rewrote my RelayCommand to below.
<div class="wp_syntax">
<table>
<tbody>
<tr>
<td class="code">
<pre class="csharp"> <span>public</span> <span>class</span> RelayCommandAsync <span>:</span> ICommand
    <span>{</span>
        <span>private</span> <span>readonly</span> Func<span>&lt;</span>T, Task<span>&gt;</span> executedMethod<span>;</span>
        <span>private</span> <span>readonly</span> Func<span>&lt;</span>T, <span>bool</span><span>&gt;</span> canExecuteMethod<span>;</span>
 
        <span>public</span> <span>event</span> EventHandler CanExecuteChanged<span>;</span>
        <span>public</span> RelayCommandAsync<span>(</span>Func<span>&lt;</span>T, Task<span>&gt;</span> execute<span>)</span> <span>:</span> <span>this</span><span>(</span>execute, <span>null</span><span>)</span> <span>{</span> <span>}</span>
 
        <span>public</span> RelayCommandAsync<span>(</span>Func<span>&lt;</span>T, Task<span>&gt;</span> execute, Func<span>&lt;</span>T, <span>bool</span><span>&gt;</span> canExecute<span>)</span>
        <span>{</span>
            <span>this</span><span>.</span><span>executedMethod</span> <span>=</span> execute <span>??</span> <span>throw</span> <span>new</span> ArgumentNullException<span>(</span><span>"execute"</span><span>)</span><span>;</span>
            <span>this</span><span>.</span><span>canExecuteMethod</span> <span>=</span> canExecute<span>;</span>
        <span>}</span>
 
        <span>public</span> <span>bool</span> CanExecute<span>(</span><span>object</span> parameter<span>)</span> <span>=&gt;</span> <span>this</span><span>.</span><span>canExecuteMethod</span> <span>==</span> <span>null</span> <span>||</span> <span>this</span><span>.</span><span>canExecuteMethod</span><span>(</span><span>(</span>T<span>)</span>parameter<span>)</span><span>;</span>
        <span>public</span> async <span>void</span> Execute<span>(</span><span>object</span> parameter<span>)</span> <span>=&gt;</span> await <span>this</span><span>.</span><span>executedMethod</span><span>(</span><span>(</span>T<span>)</span>parameter<span>)</span><span>;</span>
        <span>public</span> <span>void</span> OnCanExecuteChanged<span>(</span><span>)</span> <span>=&gt;</span> CanExecuteChanged<span>?.</span><span>Invoke</span><span>(</span><span>this</span>, EventArgs<span>.</span><span>Empty</span><span>)</span><span>;</span>
    <span>}

</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</article></div>
</div>
</div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Refer azure runbook activity output in PowerShell expression</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/refer-azure-runbook-activity-output-in-powershell-expression</link>
      <pubDate>Thu, 03 Nov 2016 13:53:20 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/?p=435</guid>
      <description><![CDATA[When you are creating a runbook with multiple activities, often you will encounter the need of...]]></description>
      <content:encoded><![CDATA[When you are creating a runbook with multiple activities, often you will encounter the need of referring an activity output in another activity. Thankfully, all the activities in the runbook can refer another activity in the parameter pane. However, when you have a piece of powershell script which needs to use the same, you don’t have a straight forward way to use it. A macro kind of option like what we have in Visual Studio would be great but as far now we are left with the mercy of our knowledge.

And so the script goes something like below.

$($ActivityOutput[`”GetSqlDbInfo`”])

&nbsp;

<a href="https://microsoftprogrammers.jebarson.com/refer-azure-runbook-activity-output-in-powershell-expression/">Read the detailed article</a>]]></content:encoded>
    </item>
    <item>
      <title>Working around the bug “Instead Of Trigger on View returns no output”</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/working-around-the-bug-instead-of-trigger-on-view-returns-no-output</link>
      <pubDate>Tue, 27 Sep 2016 15:22:10 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/?p=426</guid>
      <description><![CDATA[This post is to help developers implement a workaround on the bug mentioned in...]]></description>
      <content:encoded><![CDATA[This post is to help developers implement a workaround on the bug mentioned in <a target="_blank" href="https://connect.microsoft.com/SQLServer/feedback/details/427666/instead-trigger-return-zero-number-into-output-identity">https://connect.microsoft.com/SQLServer/feedback/details/427666/instead-trigger-return-zero-number-into-output-identity</a>

Read my post at <a href="https://microsoftprogrammers.jebarson.com/bug-instead-of-trigger-on-view-returns-no-output/">https://microsoftprogrammers.jebarson.com/bug-instead-of-trigger-on-view-returns-no-output/</a> which explains one of the work around which may come handy to you]]></content:encoded>
    </item>
    <item>
      <title>Get text from RichTextBlockOverflow Control</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/get-text-from-richtextblockoverflow-control</link>
      <pubDate>Mon, 06 Jun 2016 15:16:12 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/?p=425</guid>
      <description><![CDATA[RichTextBlockOverflow is one of my favorite control. As we all know, it allows you to render the...]]></description>
      <content:encoded><![CDATA[RichTextBlockOverflow is one of my favorite control. As we all know, it allows you to render the overflown text from a RichTextBlock. Virtually you can render the overflow text to any number of level.

Below is how a the overflow happens when you got one RichTextBlock and two RichTextBlockOverflow to render the overflown text.

<a href="https://microsoftprogrammers.jebarson.com/get-text-richtextblockoverflow-control/" target="_blank">Read more...</a>]]></content:encoded>
    </item>
    <item>
      <title>A poor man’s implementation of row level security in SQL</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/a-poor-mans-implementation-of-row-level-security-in-sql</link>
      <pubDate>Mon, 02 Nov 2015 01:32:50 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/2015/11/02/a-poor-mans-implementation-of-row-level-security-in-sql/</guid>
      <description><![CDATA[Often I have come across situations where the enterprise customers want to restrict data...]]></description>
      <content:encoded><![CDATA[<p>Often I have come across situations where the enterprise customers want to restrict data availability to their employees / IT not only from the application but also at the database level. Government / Public sectors have a common requirement that they don&rsquo;t want everybody at their IT team to be able to query everybody&rsquo;s data.</p>
<p>As of today there is no out of the box support for this feature in on premise SQL. The implementation we are going to talk about is not something new but a pretty commonly used logic in Dynamics CRM. I call it &ldquo;filtered views&rdquo;.</p>
<p>&nbsp;</p>
<p><a href="https://microsoftprogrammers.jebarson.com/a-poor-mans-implementation-of-row-level-security-in-sql/">Read more at my blog</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Complete XAML Solution For SelectAll In Datagrid</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/complete-xaml-solution-for-selectall-in-datagrid</link>
      <pubDate>Fri, 04 Jan 2013 20:30:58 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/2013/01/04/complete-xaml-solution-for-selectall-in-datagrid/</guid>
      <description><![CDATA[Over the period of time lot of asks and solutions were made for selectall selector for DataGrid....]]></description>
      <content:encoded><![CDATA[<p>Over the period of time lot of asks and solutions were made for selectall selector for DataGrid. However,&nbsp;I failed to see a solution which is completely built on XAML. When my friend approached me, I thought that I will write my own.</p>
<p>The idea is to have a template column with a separate definition for the header and the rows. To avoid using code behind for the solution, I decided to use two data templates for the header and the row items.</p>
<p><a href="https://jebarson.info/post/2013/01/05/complete-xaml-solution-for-selectall-in-datagrid.aspx">Read More</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Pin / Unpin Control Template For Toggle Button</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/pin-unpin-control-template-for-toggle-button</link>
      <pubDate>Wed, 29 Aug 2012 12:05:21 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/2012/08/29/pin-unpin-control-template-for-toggle-button/</guid>
      <description><![CDATA[I was looking for a template which will help put a pin / unpin button using toggle...]]></description>
      <content:encoded><![CDATA[<p>I was looking for a template which will help put a pin / unpin button using toggle button.&nbsp;Antoni Dol who has already shared a fantastic template and I&nbsp;had to make few changes with respective to the pinned style as I didn&rsquo;t like the original one.</p>
<p><a href="https://jebarson.info/post/2012/08/29/pin-unpin-control-template-for-toggle-button.aspx">Read More</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How To Check If Cookies Are Enabled In Windows Phone</title>
      <link>https://docs.microsoft.com/archive/blogs/jebarson/how-to-check-if-cookies-are-enabled-in-windows-phone</link>
      <pubDate>Mon, 07 May 2012 07:55:19 GMT</pubDate>
      <dc:creator><![CDATA[Jebarson J]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jebarson/2012/05/07/how-to-check-if-cookies-are-enabled-in-windows-phone/</guid>
      <description><![CDATA[Windows Phone as of today doesn&rsquo;t provide a property or direct API call which will help you...]]></description>
      <content:encoded><![CDATA[<p>Windows Phone as of today doesn&rsquo;t provide a property or direct API call which will help you identify whether the user has chosen to accept cookies or not. However, we can identify this pretty neatly by trying to get the cookie collection.<br />&nbsp;<br />So to achieve this, we are going to get the cookie collection for a site which uses cookies and if it returns empty, then the user has turned off the cookies and if it has a count, then the user has preferred to use the cookies.&nbsp; <a title="Read More" href="https://jebarson.info/post/2012/05/04/how-to-check-if-cookies-are-enabled-in-windows-phone.aspx">Read More</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>