关于SQLite整数和整型数据类型的问题

问题描述 投票:3回答:3

我遇到有关以下问题:基于SQLite提供程序运行SubSonic.Examples.SimpleRepo项目时,无法将[System.Int64类型的对象转换为System.Int32类型]]。

我喜欢表类别的列类别ID的数据类型为'integer',而SQLite中的'integer'将作为Int64

返回,与此同时Class中类别ID的数据类型类别为int,发生了以上错误。

我检查了SubSonic的源代码:\ SubSonic.Core \ SQLGeneration \ Schema \ SQLiteSchema.cs并找到以下代码:

else if (column.IsPrimaryKey && column.DataType == DbType.Int32
    || column.IsPrimaryKey && column.DataType == DbType.Int16
    || column.IsPrimaryKey && column.DataType == DbType.Int64
    )
    sb.Append(" integer ");

谁能告诉我这些代码的用途?如何解决数据类型转换错误?

我遇到一个问题:基于SQLite提供程序运行SubSonic.Examples.SimpleRepo项目时,无法将类型'System.Int64'的对象转换为类型'System.Int32'。我喜欢数据类型...

c# sqlite subsonic subsonic3
3个回答
7
投票

有趣的是,大约一个小时前,我刚刚阅读了sqlite3文档。所以你很幸运:)

[See the doc yourself(滚动到底部的64位ROWIDs部分)。


7
投票

在SQLite中,PrimaryKey设置为int 64(长整数-因此,您也需要将其设置为long。)>


0
投票

我只是通过合并过程结结巴巴,获取一个SQL Server DataTable并将其与SQLite DataTable(c#.NET Win Forms应用程序)合并(向上插入)。您肯定需要将SQL Server数据库中的整数PK列设置为BIGINT才能使它生效。否则,当您在SQLite DataTable上调用merge时,会出现类型不匹配错误。

© www.soinside.com 2019 - 2024. All rights reserved.