title: Problems Fluent Nhibernate Mapping MySQL Time(6) to C# DateTime
body: <p>i have a MySql table with the following schema</p>
  
  <pre><code>Field   Type            Null    Key Default Extra
  id          int(11)         NO  PRI NULL    auto_increment
  Date    date            YES MUL NULL    
  Time    time(6)         NO  MUL NULL    
  Exch    varchar(45) YES MUL NULL    
  ProdType    varchar(45) YES     NULL    
  Product varchar(45) YES     NULL    
  Contract    varchar(45) YES     NULL    
  Direction   varchar(45) YES     NULL    
  Price   decimal(10,4)   YES     NULL    
  Quantity    int(11)         YES     NULL    
  </code></pre>
  
  <p>Fluent Model:</p>
  
  <pre><code>public class Trade
  {
      public virtual int Id { get; set; }
      public virtual DateTime Date { get; set; }
      public virtual DateTime Time { get; set; }
      public virtual string Contract { get; set; }
      public virtual string Direction { get; set; }
      public virtual double Price { get; set; }
      public virtual int Quantity { get; set; }
  }
  </code></pre>
  
  <p>and mapping:</p>
  
  <pre><code>public TradeMap()
      {
          Id(x =&gt; x.Id).Column("id");
          Map(x =&gt; x.Date).Column("Date");
          Map(x =&gt; x.Time).Column("Time").CustomType("timestamp");;
          Map(x =&gt; x.Contract).Column("Contract");
          Map(x =&gt; x.Direction).Column("Direction");
          Map(x =&gt; x.Price).Column("Price");
          Map(x =&gt; x.Quantity).Column("Quantity");
          Table("ts");
      }
  </code></pre>
  
  <p>I'm testing the ORM with the following code</p>
  
  <pre><code>        DateTime dayStart = Convert.ToDateTime("11:31:00.000000");
          DateTime dayEnd = Convert.ToDateTime("11:32:00.000000");
  
          IQueryable&lt;Trade&gt; result = from ts in repo.GetList&lt;Trade&gt;()
                       where ts.Date == new DateTime(2013,7,1)
                          &amp;&amp; ts.Time &gt;= dayStart
                          &amp;&amp; ts.Time &lt;= dayEnd
                          &amp;&amp; ts.Contract == "Sep13"
                      select ts;
  
  
          foreach (var l in result)
          {
              DateTime k = l.Time;
          }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Trade result = repo.GetList&lt;Trade&gt;().FirstOrDefault();
  </code></pre>
  
  <p>But i keep getting inner exception</p>
  
  <pre><code>{"Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'."}
  </code></pre>
  
  <p>i tried resolving this by changing the time mapping to </p>
  
  <pre><code>Map(x =&gt; x.Time).Column("tsTime").CustomType("timestamp").CustomSqlType("TIME(6)").Nullable();
  </code></pre>
  
  <p>Map(x => x.Time).Column("tsTime").CustomSqlType("TIME(6)");</p>
  
  <p>but nothing works</p>