title: Store enums in sql-server using Linq-to-sql
body: <p>How do you store enums in sql-server using linq-to-sql?</p>
  
  <p>I end up having a lot of conversions to and from <code>int</code> in my code.
  There has to be a better way. What did I miss?</p>
  
  <pre><code>sqlItem.enumValue = (int)myEnumValue;
  ...
  myEnumValue = (MyEnumType)sqlItem.enumValue
  </code></pre>
  
  <p>It does not matter if SQL server or LINQ stores the values as strings or ints in the database, I just want to avoid all these typecasts sprinkled all over my code.</p>
  
  <p>Could it be solved by an extension method to my linq-to-sql-classes and if so what would that look like?</p>