title: How to map enum as string in database
body: <p>My table:</p>
  
  <pre><code>create table MyTable (
      Id int identity(1,1) not null,
      MyStatus char(2) not null
  )
  insert into MyTable(MyStatus) select 'A'
  </code></pre>
  
  <p>Class and enum:</p>
  
  <pre><code>public class MyTable
  {
      public virtual int Id { get; set; }
      public virtual MyTableStatus MyStatus { get; set; }
  }
  
  public enum MyTableStatus
  {
      A,
      B
  }
  </code></pre>
  
  <p>Mapping:</p>
  
  <pre><code>public MyTableMap()
  {
      Id(x =&gt; x.Id);
      Map(x =&gt; x.MyStatus);
  }
  </code></pre>
  
  <p>When I execute the following test, I get System.FormatException : Input string was not in a correct format...</p>
  
  <pre><code>[Test]
  public void Blah()
  {
      MyTable myTable = Session.Get&lt;MyTable&gt;(1);
      Assert.That(myTable.MyStatus, Is.EqualTo(MyTableStatus.A));
  }
  </code></pre>
  
  <p>What is the right way to map an enum to it's string representation in the database?</p>
  
  <p>Edit - I am writing my application on an existing database, which I cannot modify easily because it is used by other applications also. So some fields in the database (which I would like to represent as enums in my application) are of type int and some of type char(2).</p>