这样声明的sqlite表:
CREATE TABLE Note(Id UNIQUEIDENTIFIER, Title TEXT)可以被Windows上的Vici CoolStorage正确读取,但在MonoTouch上,会抛出以下异常:
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type. at Vici.CoolStorage.CSDataProviderSQLite.GetSchemaColumns (System.String tableName) [0x00000] in <filename unknown>:0 at Vici.CoolStorage.CSSchema.CreateColumns () [0x00000] in <filename unknown>:0 at Vici.CoolStorage.CSSchema..ctor (System.Type objType) [0x00000] in <filename unknown>:0 at Vici.CoolStorage.CSSchema.Get (System.Type objectType) [0x00000] in <filename unknown>:0 at Vici.CoolStorage.CSList``1[Store.CoolStorage.Note]..ctor () [0x00000] in <filename unknown>:0
根据类型ID检测列的数据类型的代码看起来不能处理Vici的MonoTouch CSDataProviderSqlite中的UNIQUEIDENTIFIER类型:
来自CSSqliteConnection.GetSchema:
switch (dbType)
{
case "TEXT": dataType = typeof(string); break;
case "VARCHAR": dataType = typeof(string); break;
case "INTEGER": dataType = typeof(int); break;
case "BOOL": dataType = typeof(bool); break;
case "DOUBLE": dataType = typeof(double); break;
case "FLOAT": dataType = typeof(double); break;
case "REAL": dataType = typeof(double); break;
case "CHAR": dataType = typeof(string); break;
case "BLOB": dataType = typeof(byte[]); break;
case "NUMERIC": dataType = typeof(decimal); break;
case "DATETIME": dataType = typeof(DateTime); break;
}这里没有UNIQUEIDENTIFIER的处理程序。这是Vici CoolStorage中的错误吗?
发布于 2013-02-12 21:14:16
我只需要修改Vici,因为看起来你有权访问源代码:
switch (dbType)
{
case "TEXT": dataType = typeof(string); break;
case "VARCHAR": dataType = typeof(string); break;
case "INTEGER": dataType = typeof(int); break;
case "BOOL": dataType = typeof(bool); break;
case "DOUBLE": dataType = typeof(double); break;
case "FLOAT": dataType = typeof(double); break;
case "REAL": dataType = typeof(double); break;
case "CHAR": dataType = typeof(string); break;
case "BLOB": dataType = typeof(byte[]); break;
case "NUMERIC": dataType = typeof(decimal); break;
case "DATETIME": dataType = typeof(DateTime); break;
case "UNIQUEIDENTIFIER": dataType = typeof(Guid); break;
}如果在此之外还有更多的需求,您将不得不尝试。除非没有尝试。利用线人,卢克。
https://stackoverflow.com/questions/14809049
复制相似问题