title: What's the simplest way to compare an enum to a integer value return from a DB
body: <p>I'm pulling some data from a table using LINQ 2 SQL...one of the pieces of data is a value that represents an enumation in my application code. </p>
  
  <p>What is the simplest way to make a comparison between the data returned in LINQ objects and the enumeration in the application code. So for example</p>
  
  <pre><code>enum SomeEnum
  {
    First
    Second
  }
  </code></pre>
  
  <p>then in the method I have</p>
  
  <pre><code>Table&lt;LinqObject&gt; objects = dc.GetTable&lt;LinqObject&gt;();
  
  foreach (var item in objects)
  {
     // What's the simplest way to do this comparison???
     if (item.SomeNullableInteger == SomeEnum.First) // Note I realise this doesn't work!!!
     {
        // Do something...
     }
  }
  </code></pre>
  
  <p>I could do this</p>
  
  <pre><code>SomeEnum.First.Equals(item.SomeNullableInteger)
  </code></pre>
  
  <p>or I could store the enumeration names in the database and then i'd be able to do this</p>
  
  <pre><code>Enum.GetName(SomeEnum, SomeEnum.First) == item.SomeNullableName
  </code></pre>
  
  <p>is there a better way? The enum only has two items and they're pretty fixed...could maybe have a third or a fourth but will probably never grow beyond that. So having a whole table seems like overkill.</p>
  
  <p>Actually this is a duplicate of <a href="https://stackoverflow.com/questions/502905/c-int-to-enum-conversion">C# int to enum conversion</a></p>