title: Invalid cast in LINQ to SQL
body: <p>I've been thrown an invalid cast exception using LINQ to SQL. Here's my class in C#:</p>
  
  <pre><code>[Table(Name = "tbl_request$")]
  public class request
  {
      [Column(IsPrimaryKey = true)]
      public float requestID;
      [Column]
      public string moduleCode;
      [Column]
      public float park;
      [Column]
      public string requestedRoom;
      [Column]
      public float week;
      [Column]
      public float day;
      [Column]
      public float period;
      [Column]
      public float status;
      [Column]
      public float semester;
      [Column]
      public float priority;
      [Column]
      public float adhoc;
      [Column]
      public float numStudents;
      [Column]
      public float collectionID;
      [Column]
      public float roomCount;
  }
  </code></pre>
  
  <p>The database table this corresponds to</p>
  
  <pre><code>requestID   float   Unchecked
  moduleCode  nvarchar(255)   Checked
  park    float   Checked
  requestedRoom   nvarchar(255)   Checked
  week    float   Checked
  day float   Checked
  period  float   Checked
  status  float   Checked
  semester    float   Checked
  priority    float   Checked
  adhoc   float   Checked
  numStudents float   Checked
  collectionID    float   Checked
  roomCount   float   Checked
  </code></pre>
  
  <p>Everything looks fine to me. Any other suggestions?</p>
  
  <pre><code>Specified cast is not valid.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.InvalidCastException: Specified cast is not valid.
  
  Source Error: 
  
  Line 12:             var bookingtable = Database.DatabaseContext.GetTable&lt;Database.request&gt;();
  Line 13:             var dict = new System.Collections.Generic.Dictionary&lt;int, System.Collections.Generic.List&lt;Database.request&gt;&gt;();
  Line 14:             foreach (var request in bookingtable)
  Line 15:             {
  Line 16:                 if (dict[(int)request.collectionID] == null)
  </code></pre>
  
  <p>The stack trace is deep inside LINQ internals.</p>