不正确的字段类型映射 SubSonic 2.2、SQLite 3

发布于 2024-08-24 04:17:02 字数 248 浏览 6 评论 0原文

我在 SQLite 表中有一个布尔 (BOOL) 类型字段。 在 SubSonic 生成的 DAL 中,它表示为字符串(而不是布尔值)。 这很奇怪。 如何对其进行管理?请帮忙。

替代文本 http://dl.dropbox.com/u/3882061/sqlite.GIF< /a>

I have a boolean (BOOL) type field in the SQLite table.
In the SubSonic generated DAL it is represented as string (instead of bool).
It is weird.
How it can be managed? Please, help.

alt text http://dl.dropbox.com/u/3882061/sqlite.GIF

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半步萧音过轻尘 2024-08-31 04:17:02

我可能错了,我只使用了 Subsonic 2.2 和 SQL2008,但我建议查看 Subsonic 的源代码,即 SQLLiteDataProvider.cs 并查看 DbType 函数。

它似乎可以识别 Boolean 类型,但不能识别 Bool 类型,并且当它无法识别您的类型时,默认情况下会求助于 String

Hare 是该函数中的有问题的代码,

 switch(sqliteType.ToLowerInvariant())
            {
                case "text":
                case "char":
                case "nchar":
                case "varchar":
                case "nvarchar":
                    return DbType.String;
                case "boolean":
                case "bit":
                    return DbType.Boolean;
                case "bigint":
                case "int":
                case "integer":
                    return DbType.Int64;
                case "real":
                case "numeric":
                case "double":
                case "single":
                case "float":
                    return DbType.Single;
                case "smallint":
                    return DbType.Int16;
                case "date":
                case "time":
                case "datetime":
                case "smalldatetime":
                case "timestamp":
                    return DbType.DateTime;
                case "binary":
                case "blob":
                case "image":
                    return DbType.Binary;
                case "guid":
                    return DbType.Guid;
                default:
                    return DbType.String;
            }

我建议对其进行更改,看看它是否有效,然后建议对亚音速小伙子进行更改。

I maybe wrong on this, I have only used Subsonic 2.2 with SQL2008 but I would recommend looking at the source for Subsonic, namely SQLLiteDataProvider.cs and reviewing the DbType function.

It seems to recognise the type Boolean but not Bool and the default when it does not recognise your type is to resort to String.

Hare is the code in question from that function

 switch(sqliteType.ToLowerInvariant())
            {
                case "text":
                case "char":
                case "nchar":
                case "varchar":
                case "nvarchar":
                    return DbType.String;
                case "boolean":
                case "bit":
                    return DbType.Boolean;
                case "bigint":
                case "int":
                case "integer":
                    return DbType.Int64;
                case "real":
                case "numeric":
                case "double":
                case "single":
                case "float":
                    return DbType.Single;
                case "smallint":
                    return DbType.Int16;
                case "date":
                case "time":
                case "datetime":
                case "smalldatetime":
                case "timestamp":
                    return DbType.DateTime;
                case "binary":
                case "blob":
                case "image":
                    return DbType.Binary;
                case "guid":
                    return DbType.Guid;
                default:
                    return DbType.String;
            }

I would recommend changing it, seeing if it works and then recommeding the change to the subsonic chaps.

错々过的事 2024-08-31 04:17:02

我在 12 月份检查了该提供程序的新版本,修复了几个错误,但据我所知,它没有包含在源下载中——Rob 不使用 sqlite,因此合并和测试不是他的优先事项。我建议查看我的版本,因为它为我解决了几个错误。我有一个更新的版本,它几乎通过了所有单元测试,针对 sqlite 进行了修改,但想知道是否值得上传它。由于数据库锁定错误和核心代码中的 sql server 偏差,测试很难通过——sqlite 具有文件级锁定。单元测试根本没有完全覆盖。

链接到我在 github 上的 SQLiteProvider.cs

我的版本有一个稍微不同的 GetDbType 方法,我发现由于一些脑死亡的原因,我没有将 bool 或 boolean 作为要转换的类型包含在内,所以我将添加它。

I checked in a newer version of the provider in Dec. with several bug fixes, but from what I can tell it's not included in the source download -- Rob doesn't work with sqlite therefore it's not a priority for him to merge and test. I recommend looking my version since it solved several bugs for me. I have an even newer version that passes virtually all of the unit tests, modified for sqlite, but wonder if it's worthwhile uploading it. It was difficult to get the tests to pass due to database locking errors and the sql server bias in the core code -- sqlite has file level locking. The unit tests are not at all complete coverage.

Link to my SQLiteProvider.cs on github

My version has a slightly different GetDbType method, and I see for some brain dead reason I didn't include bool or boolean as a type to convert so I will add that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文