SQLite Int64 vs Int32 Problem and SubSonic ActiveRecord

I thought it was covered elsewhere, but I do not see it now. Anyway, the problem is with a simple v3 request. Using SQLite ADO.NET provider 1.0.65.0. My table structure looks like this:

CREATE TABLE "SamplerData" ("RowId" INT PRIMARY KEY  NOT NULL ,"SampName" VARCHAR(128),"SampPurpose" VARCHAR(2048),"ActiveState" INTEGER NOT NULL  DEFAULT 1 )

The file My Structs1.cs has this:

        Columns.Add(new DatabaseColumn("RowId", this)
        {
                IsPrimaryKey = true,
                DataType = DbType.Int32,
                IsNullable = false,
                AutoIncrement = false,
                IsForeignKey = false
        });

        Columns.Add(new DatabaseColumn("SampName", this)
        {
                IsPrimaryKey = false,
                DataType = DbType.AnsiString,
                IsNullable = true,
                AutoIncrement = false,
                IsForeignKey = false
        });

        Columns.Add(new DatabaseColumn("SampPurpose", this)
        {
                IsPrimaryKey = false,
                DataType = DbType.AnsiString,
                IsNullable = true,
                AutoIncrement = false,
                IsForeignKey = false
        });

        Columns.Add(new DatabaseColumn("ActiveState", this)
        {
                IsPrimaryKey = false,
                DataType = DbType.Int32,
                IsNullable = false,
                AutoIncrement = false,
                IsForeignKey = false
        });

I have a query in WPF code that looks like this:

SqlQuery sqlsql = new Select()
  .From( "SamplerData" )
  .Where( "ActiveState" )
  .IsEqualTo( 1 );
List<SamplerDatum> sampAll = sqlsql .ExecuteTypedList<SamplerDatum>();

The breakpoint set to display the sqlsql value shows this:

{SELECT * FROM `SamplerData` WHERE ActiveState = @0}

Then the code throws:

{"An object of type" System.Int64 "cannot be converted to type" System.Int32 "." }

Visual Studio Search did not show me where the Int64 conversion took place. I understand that SQLite uses Int64 for identity columns, but not why / how SubSonic handles the conversion when Structs makes it Int32 anyway.

?!

..

+3
2

SubSonic, ADO.NET sqlite int64 . SubSonic, , DbType.Int32 DbType.Int64.

, , ( ADO.NET) SubSonic - , , , 32- DbType.Int32. long int (.. (int)(object)(long)0 ) - SubSonic, 64- , , SQLite .

+4

- SQLite.tt PK long (int 64). Github, . , .

+9

Source: https://habr.com/ru/post/1716108/


All Articles