title: Linq To Sql: How to convert Hexadecimal to Decimal
body: <p>This is the Linq To SQL query I am trying to execute. However, Int64.Parse fails as there is no Hexadecimal to Decimal equivalent in SQL. </p>
  
  <p>Basically, I have 2 columns Guid1 and Guid2 expecting to get a result where for example <code>1 -&gt; 2</code> and <code>2 -&gt; 1</code> are grouped together.</p>
  
  <pre><code>SomeTable.GroupBy(x =&gt; new { 
      Max = Math.Max(Int64.Parse(x.Guid1.Replace('-','0').Substring(0,15),16),
                  Int64.Parse(x.Guid2.Replace('-','0').Substring(0,15),16) ),
      Min = Math.Min(Int64.Parse(x.Guid1.Replace('-','0').Substring(0,15),16),
                  Int64.Parse(x.Guid2.Replace('-','0').Substring(0,15),16))
  })
  </code></pre>
  
  <p><strong>EDIT:</strong> To Add More Context, please refer to <a href="https://stackoverflow.com/q/31989230/3955513">Linq distinct based on two columns</a>
  The only difference here is except for number columns, we have GUID columns.</p>