我正在进行一个 Web 服务调用,它返回一个包含 50 个数据包的消息 bean。然后我通过以下方式将它放入我的 SQLite
public void DashboardHandler(Array Bean, long cNum)
{
foreach (invoiceSummaryBean ib in Bean)
{
var dash = new dashboardCustomer
{
actualUsage = ib.actualUsage,
serviceCost = ib.serviceCost,
mmbtu = ib.mmbtu,
OptiServiceCost = ib.optimizedServiceCost,
period = ib.period,
periodType = ib.periodType,
service = ib.service,
serviceType = ib.serviceType,
measure = ib.unitOfMeasure,
customerNumber = cNum
};
try
{
db.insertDashboard(dash);
}
catch
{
}
}
}
我的插入方法
public async Task insertDashboard(dashboardCustomer d)
{
try
{
await db.InsertAsync(d);
}
catch(SQLiteException)
{
throw;
}
}
我的桌子
[Table("dashboardCustomer")]
public class dashboardCustomer
{
public long customerNumber { get; set; }
public int period { get; set; }
public string periodType { get; set; }
public string service { get; set; }
public double actualUsage { get; set; }
public double mmbtu { get; set; }
public double OptiServiceCost { get; set; }
public double serviceCost {get; set;}
public string serviceType { get; set; }
public string measure { get; set; }
}
当它尝试插入时崩溃说{“约束”}?
不确定是什么问题。我需要将所有 50 个数据包插入表中。