我正在尝试使用 Dapper 查询 Sqlite 表,如下所示:
CREATE TABLE "Running" (
"Id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
"MachineName" BLOB NOT NULL DEFAULT 'machine' UNIQUE,
"IsOnline" INTEGER DEFAULT 0,
"TimesRan" INTEGER DEFAULT 0,
"LoginDateTime" TEXT,
"LogoutDateTime" TEXT,
"ForceUpgrade" INTEGER NOT NULL DEFAULT 0,
"Version" TEXT
)
目前在该表中我只有一条记录:
1
DESKTOP-KQT7CGC
0
1
2019-09-21 03:04:10.099067
2019-09-21 03:04:37.6825109
0
4.0.0
var data = await _globalConfig.Connection.GetStatusAsync();
public async Task<List<ApplicationInfoModel>> GetStatusAsync()
{
using (IDbConnection cnn = new SQLiteConnection(ConfigurationManager.GetLocalOrSharedConnectionString(), true))
{
var output = await cnn.QueryAsync<ApplicationInfoModel>("select * from Running", new DynamicParameters());
return output.ToList();
}
}
ApplicationInfoModel 看起来像这样:
public class ApplicationInfoModel
{
public int Id { get; set; }
public string MachineName { get; set; }
public bool IsOnline { get; set; }
public int TimesRan { get; set; }
public DateTime LoginDateTime { get; set; } = DateTime.Now;
public DateTime LogoutDateTime { get; set; }
public bool ForceUpgrade { get; set; }
public string Version { get; set; }
}
我收到了 System.Data.DataException,其中包含消息 Error parsing column 1 (MachineName=System.Byte[] - Object)。
有人可以帮助我理解为什么我应该在模型上实现IConvertible
吗?
我尝试仅针对 属性实现 IConvertible
,但它仍然引发相同的异常。MachineName
慕仙森
相关分类