SQLite Int64 vs Int32 Problem and SubSonic ActiveRecord SQLite Int64 vs Int32 Problem and SubSonic ActiveRecord sqlite sqlite

SQLite Int64 vs Int32 Problem and SubSonic ActiveRecord


We fixed this with the latest release - the SQLite.tt file didn't correctly translate the integer PK to long (int 64). If you grab the latest bits at Github it should be solved. Make sure you grab from the templates project.


I don't know much about SubSonic, but the ADO.NET client for sqlite uses int64 for all integer columns. Without knowing SubSonic, this is just a guess, but you may want to change the DbType.Int32 columns to DbType.Int64.

Most likely, the query is actually executing fine, but the return values (untyped initially, in ADO.NET fashion) are being unboxed into some SubSonic data structures - structures it thinks should be 32-bit integers, based on your DbType.Int32 statement. You cant unbox a long into an int (i.e. (int)(object)(long)0 will throw an Exception) - so you need to tell SubSonic to expect 64-bit integers, since that's what SQLite is going to give you.