Vici CoolStorage是否支持UniqueIdentifier键用于MonoTouch?

时间:2013-02-11 09:16:52

标签: xamarin.ios uniqueidentifier coolstorage

声明如下的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中的一个错误吗?

1 个答案:

答案 0 :(得分:3)

我只想修改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;
}

如果除此之外还有其他要求,您必须尝试。除非没有尝试。使用来源,Luke。