<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Ruzenhack</title>
    <description>The latest articles on DEV Community by Alex Ruzenhack (@alexruzenhack).</description>
    <link>https://dev.to/alexruzenhack</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1703%2F5992210.jpeg</url>
      <title>DEV Community: Alex Ruzenhack</title>
      <link>https://dev.to/alexruzenhack</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexruzenhack"/>
    <language>en</language>
    <item>
      <title>Reads of the week</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Wed, 03 Oct 2018 23:48:09 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/reads-of-the-week-4loa</link>
      <guid>https://dev.to/alexruzenhack/reads-of-the-week-4loa</guid>
      <description>&lt;p&gt;I consume some articles on Medium every week, some of them made me reevaluate my learning strategies, or improve my coding habit, or just let me know some useful career tip. Sometimes I feel the content could reach more people. So I'm bringing them to my audience here, first as a general test. Feel free to contact me or discuss one or two subjects of the reading list.&lt;/p&gt;

&lt;h2&gt;
  
  
  #Programming #Architecture
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://jeffreypalermo.com/2008/07/the-onion-architecture-part-1/"&gt;The Onion Architecture : part 1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://8thlight.com/blog/uncle-bob/2011/09/30/Screaming-Architecture.html"&gt;Screaming Architecture&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html"&gt;The Clean Architecture&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/microsoft-open-source-stories/how-microsoft-rewrote-its-c-compiler-in-c-and-made-it-open-source-4ebed5646f98"&gt;How Microsoft rewrote its C# compiler in C# and made it open source&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  #Security
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.freecodecamp.org/discovering-the-hidden-mine-of-credentials-and-sensitive-information-8e5ccfef2724"&gt;How I used a simple Google query to mine passwords from dozens of public Trello boards&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  #Ethic #Neuroscience #Future
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/s/story/yes-you-should-delete-facebook-heres-why-bc623a3b4625"&gt;Yes, You Should Delete Facebook&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/@ermanmisirlisoy/why-we-all-hate-hypocrites-3194a04d3141"&gt;Why We All Hate Hypocrites&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/s/futurehuman/survival-of-the-richest-9ef6cddd0cc1"&gt;Survival of the Richest&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Did you find any article useful? Which one? Why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>work</category>
      <category>ethic</category>
    </item>
    <item>
      <title>Reads of the week</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Thu, 27 Sep 2018 00:03:12 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/reads-of-the-week-4bie</link>
      <guid>https://dev.to/alexruzenhack/reads-of-the-week-4bie</guid>
      <description>&lt;p&gt;I consume some articles on Medium every week, some of them made me reevaluate my learning strategies, or improve my coding habit, or just let me know some useful career tip. Sometimes I feel the content could reach more people. So I'm bringing them to my audience here, first as a general test. Feel free to contact me or discuss one or two subjects of the reading list.&lt;/p&gt;

&lt;h3&gt;
  
  
  #Learning #Writing #Productivity
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/taking-note/learning-from-the-feynman-technique-5373014ad230"&gt;Learning From the Feynman Technique&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/commitlog/why-i-still-use-vim-67afd76b4db6"&gt;Why I Still Use Vim&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/swlh/the-power-of-culture-how-to-hire-and-attract-amazing-people-fd9e37b6d520"&gt;The power of culture: how to hire and attract amazing people&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/personal-growth/george-orwells-six-rules-for-great-writing-4db6d31ff136"&gt;George Orwell’s Six Rules For Great Writing&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  #Programming
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.freecodecamp.org/code-comments-the-good-the-bad-and-the-ugly-be9cc65fbf83"&gt;Putting comments in code: the good, the bad, and the ugly.&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/@plainprogrammer/tests-should-not-be-optional-579151593ebc"&gt;Tests Should Not Be Optional&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  #Work #Careers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.freecodecamp.org/genuinely-useful-career-resources-for-self-taught-developers-8e679cec25ab"&gt;Genuinely useful career resources for self-taught developers&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/thrive-global/ikigai-the-japanese-secret-to-a-long-and-happy-life-might-just-help-you-live-a-more-fulfilling-9871d01992b7"&gt;Ikigai: The Japanese Secret to a Long and Happy Life Might Just Help You Live a More Fulfilling Life&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  #AI #Blockchain
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://blog.goodaudience.com/the-future-of-ai-is-on-blockchain-1b4049ae2963"&gt;The future of AI is on blockchain&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://arcdigital.media/is-the-singularity-coming-ef8580d4ce97"&gt;Is The Singularity Coming?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  #Basic Income
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/basic-income/the-real-story-of-automation-beginning-with-one-simple-chart-8b95f9bad71b"&gt;The Real Story of Automation Beginning with One Simple Chart&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  #Life Lessons #Self Improvement
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/personal-growth/the-3-keys-to-becoming-irresistible-d2f689ea4bf1"&gt;The 3 Keys to Becoming Irresistible&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Did you find any article useful? Which one? Why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>programming</category>
      <category>work</category>
    </item>
    <item>
      <title>Using C# LINQ API to perform SQL IN logic at WHERE clause</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Thu, 30 Aug 2018 12:24:58 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/using-c-linq-api-to-perform-sql-in-logic-at-where-clause-i5f</link>
      <guid>https://dev.to/alexruzenhack/using-c-linq-api-to-perform-sql-in-logic-at-where-clause-i5f</guid>
      <description>&lt;p&gt;I was working on a project with &lt;code&gt;User&lt;/code&gt; and &lt;code&gt;Costumer&lt;/code&gt; identificação. The first is generated by the web app, and the second by the business department.&lt;/p&gt;

&lt;p&gt;So I had to develop a logic to make those match between identifications. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;User&lt;/code&gt; entity needs to know the &lt;code&gt;Costumer&lt;/code&gt; identification and, in order to make the match, first I selected the users without a costumer and extracted a list of emails. Then, I selected the customers based on this email list. This statement can be transcribed to SQL syntax, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Customers&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;CustomerId&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But how to translate the SQL to C# LINQ API?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, make the selection from Users, extracting the list of emails&lt;/li&gt;
&lt;li&gt;Select the Customers with those emails&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;emails&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_userManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CustomerId&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// extract the emails from users&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_applicationRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetCustomers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;emails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;// the Contains method carry the IN logic when translated to SQL script&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have the match programmatically.&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://weblogs.asp.net/dwahlin/using-linq-to-perform-quot-where-in-value1-value2-quot-queries"&gt;Using LINQ to Perform "WHERE IN (Value1,Value2)" Queries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/sql/t-sql/language-elements/in-transact-sql?view=sql-server-2017"&gt;IN(Transact-SQL)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/pt-br/dotnet/api/system.linq.queryable.contains?view=netframework-4.7.2"&gt;Queryable.Contains Method &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linqpad.net/"&gt;LINQPad - The .NET Programmer’s Playground &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>csharp</category>
      <category>sql</category>
      <category>linq</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>Add a unique nullable index to an entity property</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Wed, 29 Aug 2018 14:11:36 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/add-a-unique-nullable-index-to-an-entity-property-25jo</link>
      <guid>https://dev.to/alexruzenhack/add-a-unique-nullable-index-to-an-entity-property-25jo</guid>
      <description>&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;I was working on an MVC project and to simplify our life, the team chose to work with the ASP.NET Core Identity Assembly to create the authentication and authorization logic of the web app.&lt;/p&gt;

&lt;p&gt;However, when a user registers yourself on the app, a new Id is generated for them, despite the company may already have one Id.&lt;/p&gt;

&lt;p&gt;Then, to link together the new Id with the natural old Id, I extended the default &lt;code&gt;IdentityUser&lt;/code&gt; to possess the &lt;code&gt;MyCompanyId&lt;/code&gt; property, this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomUser&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IdentityUser&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;MyCompanyId&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in order to make this change effective I extended the &lt;code&gt;IdentityDbContext&lt;/code&gt; to use my &lt;code&gt;CustomUser&lt;/code&gt; and also to register the property &lt;code&gt;MyCompanyId&lt;/code&gt; as a unique index, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomDbContext&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IdentityDbContext&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;CustomUser&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;CustomDbContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DbContextOptions&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;CustomDbContext&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;OnModelCreating&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ModelBuilder&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;OnModelCreating&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Entity&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;CustomUser&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; 
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;HasIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MyCompanyId&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;IsUnique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this, when a user registers yourself a default value is assigned to &lt;code&gt;MyCompanyId&lt;/code&gt; property, which is &lt;code&gt;0&lt;/code&gt;. When another user tries to register, the same value will be assigned to their &lt;code&gt;MyCompanyId&lt;/code&gt;, and it will throw an error of duplicate key.&lt;/p&gt;

&lt;p&gt;It occurs because when the entity is transcribed to a fluentish API for migration, by default, the column is set as non-nullable and a default value must be assigned, as we saw &lt;code&gt;0&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// hidden for brevity&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;migrationBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateTable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AspNetUsers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="n"&gt;MyCompanyId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the index assigns uniqueness to all values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// hidden for brevity&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;migrationBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"IX_AspNetUsers_MyCompanyId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AspNetUsers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"MyCompanyId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;How to solve this all, and allow a nullable unique index? It's &lt;strong&gt;so&lt;/strong&gt; simple, man! Just add the &lt;code&gt;?&lt;/code&gt; symbol after the type of the property, this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomUser&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IdentityUser&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;MyCompanyId&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the property is optional and it will be propagated all way down. Let's see the migration fluentish API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// hidden for brevity&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;migrationBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateTable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AspNetUsers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
        &lt;span class="n"&gt;MyCompanyId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// now it's true&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the index has a new variable &lt;code&gt;filter&lt;/code&gt; which skip the null values as unique. It means you can have as many null values as you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// hidden for brevity&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;migrationBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"IX_AspNetUsers_MyCompanyId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AspNetUsers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"MyCompanyId"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"[MyCompanyId] IS NOT NULL"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>entityframework</category>
      <category>dotnetcoreidentity</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>What do you do in your two hours out of home?</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Sun, 26 Aug 2018 21:24:18 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/what-do-you-do-in-your-two-hours-out-of-home-4h6b</link>
      <guid>https://dev.to/alexruzenhack/what-do-you-do-in-your-two-hours-out-of-home-4h6b</guid>
      <description>&lt;p&gt;I read the &lt;a href="https://insights.stackoverflow.com/survey/2018/#developer-profile-how-much-time-do-developers-spend-outside" rel="noopener noreferrer"&gt;StackOverflow statistics for this year (2018)&lt;/a&gt; and it shows the time developers spend outside is about 30min to 2h per day.&lt;/p&gt;

&lt;p&gt;This number is very reasonable, by my self. Now I'm curious about: &lt;strong&gt;What you do at this time?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;During the work week I spend time riding a bike and exercising me, and at the weekend I try to know the cool places in my city, like the "Two Brothers Hill" in Rio de Janeiro.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Furu93rlmhp2cq7omjyjl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Furu93rlmhp2cq7omjyjl.jpg" alt="Two Brothers Hill"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>outsidehome</category>
    </item>
    <item>
      <title>Passing serialized C# object in JSON to Razor Page</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Fri, 24 Aug 2018 16:18:50 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/passing-serialized-c-object-in-json-to-razor-page-2h48</link>
      <guid>https://dev.to/alexruzenhack/passing-serialized-c-object-in-json-to-razor-page-2h48</guid>
      <description>&lt;p&gt;I was working in a way to convey a dataset coming from the database to Google Chart JavaScript framework, using C# and .NET Core MVC framework under the Razor Page.&lt;/p&gt;

&lt;p&gt;The first step was easy, a trivial query to the database in order to get the data, but Google Chart has their special way to handle a dataset and to realize a simple conversion from POCO was not sufficient, then I wrote a converter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;poco2GoogleChartDataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;MyData&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;googleDataset&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyData&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Array&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;object&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="n"&gt;googleDataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;googleDataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result of this conversion was serialized to JSON using the &lt;code&gt;Newtonsoft.Json&lt;/code&gt; assembly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Top of the class&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Newtonsoft.Json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Hidden for brevity&lt;/span&gt;
&lt;span class="n"&gt;ReportJson&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonConvert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SerializeObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;poco2GoogleChartDataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myDataset&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the other hand, in Razor Page, I need to pass this JSON object to a JavaScript variable. If you just pass the model value using a simple Razor syntax, it will not work because in the Razor Render process will pass the value through an HTML encoding. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Razor Page&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;@section&lt;/span&gt; &lt;span class="n"&gt;Scripts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;drawChart&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;jsonDataset&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;@Model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReportJson&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jsonDataset result:
[[\&amp;amp;#x22;Label\&amp;amp;#x22;, value]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To bypass the HTML encoding wrap the model variable into the HtmlHelper directive with their &lt;code&gt;Raw&lt;/code&gt; method. This way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Razor Page&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;@section&lt;/span&gt; &lt;span class="n"&gt;Scripts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;drawChart&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;jsonDataset&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;@Html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReportJson&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the value result will be a JSON object, ready to be used in Google Chart framework.&lt;/p&gt;

&lt;p&gt;I suffered hours to achieve this comprehension, in part because I do not master Razor syntax, nor ASP.NET Core MVC, neither the C# 😂&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>json</category>
      <category>razor</category>
    </item>
    <item>
      <title>Git merge specific file from another branch</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Thu, 23 Aug 2018 21:04:12 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/git-merge-specific-file-from-another-branch-dl</link>
      <guid>https://dev.to/alexruzenhack/git-merge-specific-file-from-another-branch-dl</guid>
      <description>

&lt;p&gt;There are two teams working on the same project and they realize a common problem that was already resolved by one side, but the status of work in each branch is &lt;code&gt;in progress&lt;/code&gt; and to make a merge can be unsafe.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How to solve this problem?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is a safe solution: &lt;em&gt;merge a specific file from another branch.&lt;/em&gt; And there is the steps:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git checkout &amp;lt;another-branch&amp;gt; &amp;lt;path-to-file&amp;gt; [&amp;lt;one-more-file&amp;gt; ...]
$ git status
$ git commit -m "'Merge' specific file from '&amp;lt;another-branch&amp;gt;'"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's it!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/"&gt;Here is a more detailed approach.&lt;/a&gt;&lt;/p&gt;


</description>
      <category>git</category>
      <category>gitmerge</category>
      <category>gitbranch</category>
    </item>
    <item>
      <title>Como criar uma aplicação REST API básica com Spark</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Mon, 14 May 2018 00:58:41 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/como-criar-uma-aplicao-rest-api-bsica-com-spark-3nkn</link>
      <guid>https://dev.to/alexruzenhack/como-criar-uma-aplicao-rest-api-bsica-com-spark-3nkn</guid>
      <description>&lt;p&gt;Através do micro framework Spark é possível criar micro serviços web com grande facilidade, envelopar num jar gordo e botar pra rodar numa micro instância Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Crie um projeto maven
&lt;/h3&gt;

&lt;p&gt;Configure o arquivo &lt;code&gt;pom.xml&lt;/code&gt; com as seguintes dependências:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependencies&amp;gt;
    &amp;lt;dependency&amp;gt;
        &amp;lt;groupId&amp;gt;com.sparkjava&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;spark-core&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;2.7.1&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;

    &amp;lt;dependency&amp;gt;
        &amp;lt;groupId&amp;gt;org.slf4j&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;slf4j-simple&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;1.7.21&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;
&amp;lt;/dependencies&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Configure a montagem do jar
&lt;/h3&gt;

&lt;p&gt;Construa um jar gordo que contenha todas as dependências do seu projeto, assim você pode rodar sua aplicação de forma independente.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;plugin&amp;gt;
    &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;maven-assembly-plugin&amp;lt;/artifactId&amp;gt;
    &amp;lt;executions&amp;gt;
        &amp;lt;execution&amp;gt;
            &amp;lt;goals&amp;gt;
                &amp;lt;goal&amp;gt;attached&amp;lt;/goal&amp;gt;
            &amp;lt;/goals&amp;gt;
            &amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;
            &amp;lt;configuration&amp;gt;
                &amp;lt;finalName&amp;gt;${project.name}&amp;lt;/finalName&amp;gt;
                &amp;lt;descriptorRefs&amp;gt;
                    &amp;lt;descriptorRef&amp;gt;jar-with-dependencies&amp;lt;/descriptorRef&amp;gt;
                &amp;lt;/descriptorRefs&amp;gt;
                &amp;lt;archive&amp;gt;
                    &amp;lt;manifest&amp;gt;
                        &amp;lt;mainClass&amp;gt;yourgroupid.sparkrest.HelloWorld&amp;lt;/mainClass&amp;gt;
                    &amp;lt;/manifest&amp;gt;
                &amp;lt;/archive&amp;gt;
            &amp;lt;/configuration&amp;gt;
        &amp;lt;/execution&amp;gt;
    &amp;lt;/executions&amp;gt;
&amp;lt;/plugin&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Crie um endpoint para sua REST API
&lt;/h3&gt;

&lt;p&gt;Crie uma classe chamada &lt;code&gt;HelloWorld&lt;/code&gt; onde você irá configurar um endpoint que receba requisições &lt;code&gt;GET&lt;/code&gt; e devolva o texto simples &lt;code&gt;Hello World&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import static spark.Spark.*;

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (req, res) -&amp;gt; "Hello World");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Rode sua aplicação
&lt;/h3&gt;

&lt;p&gt;Pra finalizar, execute esse script para compilar sua aplicação&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$&amp;gt; mvn dependency:resolver
$&amp;gt; mvn verify
$&amp;gt; mvn package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Agora execute o jar gordo compilado&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$&amp;gt; java -jar nomedoprojeto-jar-with-dependencies.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Faça uma requisição na URL &lt;code&gt;http://localhost:4567/hello&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Resposta
Hello World
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusão
&lt;/h3&gt;

&lt;p&gt;O Spark oferece uma solução de micro serviço para aplicações web REST API com requisições bloqueantes, isto é, uma requisição fica presa numa tread. Portanto, a recomendação é que as aplicações construídas sobre esse framework sejam simples.&lt;/p&gt;

&lt;p&gt;Para escalar aplicações que utilizem essa tecnologia é preciso usar uma arquitetura de microserviços com load balancer e criar novas instâncias de acordo com a demanda.&lt;/p&gt;

</description>
      <category>spark</category>
      <category>java</category>
      <category>microservices</category>
    </item>
    <item>
      <title>ConfiguraÃ§Ã£o bÃ¡sica de processos em paralelo do PostgreSQL</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Tue, 24 Jan 2017 18:04:42 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/configurao-bsica-de-processos-em-paralelo-do-postgresql</link>
      <guid>https://dev.to/alexruzenhack/configurao-bsica-de-processos-em-paralelo-do-postgresql</guid>
      <description>&lt;p&gt;Para gerar uma execuÃ§Ã£o paralela de planos Ã© acrescentado um &lt;em&gt;nÃ³-de-reuniÃ£o&lt;/em&gt; ao &lt;em&gt;nÃ³-geral&lt;/em&gt; do plano de execuÃ§Ã£o. Na etapa de execuÃ§Ã£o, quando o &lt;em&gt;nÃ³-de-reuniÃ£o&lt;/em&gt; Ã© atingido, entÃ£o o processo principal faz a requisiÃ§Ã£o de alguns outros processos de execuÃ§Ã£o para trabalhar o plano do &lt;em&gt;nÃ³-de-reuniÃ£o&lt;/em&gt; em paralelo ao plano do &lt;em&gt;nÃ³-geral&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;No entanto, hÃ¡ um limite de processos em paralelo estabelecido pelo sistema e isso pode impactar negativamente a performance da query em execuÃ§Ã£o.&lt;/p&gt;

&lt;p&gt;A soluÃ§Ã£o Ã© alterar a variÃ¡vel de sistema &lt;code&gt;max_worker_processes&lt;/code&gt; para um limite superior, ou reduzir o nÃºmero mÃ¡ximo de processos em cada &lt;em&gt;nÃ³-de-reuniÃ£o&lt;/em&gt; atravÃ©s da variÃ¡vel de sistema &lt;code&gt;max_parallel_workers_per_gather&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>parallelquery</category>
    </item>
    <item>
      <title>Hi, I'm Alex Ruzenhack</title>
      <dc:creator>Alex Ruzenhack</dc:creator>
      <pubDate>Fri, 13 Jan 2017 19:25:06 +0000</pubDate>
      <link>https://dev.to/alexruzenhack/hi-im-alex-ruzenhack</link>
      <guid>https://dev.to/alexruzenhack/hi-im-alex-ruzenhack</guid>
      <description>&lt;p&gt;I have been coding for 2 years.&lt;/p&gt;

&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/alexruzenhack" rel="noopener noreferrer"&gt;alexruzenhack&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Rio de Janeiro, Brazil.&lt;/p&gt;

&lt;p&gt;I work for Nas11&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: Java, SQL, Ruby and Python.&lt;/p&gt;

&lt;p&gt;I am currently learning more about Cyber Security.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
