2013-02-11 48 views
2

一个SQLite表声明如下:Vici CoolStorage支持MonoTouch的UniqueIdentifier密钥?

CREATE TABLE Note(Id UNIQUEIDENTIFIER, Title TEXT) 

正确的维西CoolStorage在Windows上阅读,但对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的CSDataProviderSqlite for MonoTouch中的UNIQUEIDENTIFIER类型:

From CSSqliteConnection.GetSch ema:

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

+0

这不是一个错误,但它没有明确支持 – 2013-02-11 10:04:42

+0

@Philippe,有没有解决这个异常在MonoTouch?谢谢。 – bright 2013-02-11 10:29:01

回答

3

我只是修改维西,因为它看起来像您可以访问源代码:

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; 
} 

如果有更多的要求,除此之外,你将不得不尝试。除非没有尝试。使用源代码,卢克。

+0

是的,这是我已经做了,但感谢尤达:)确认这是正确的做法。 – bright 2013-02-12 20:30:48

相关问题