2
我正在做一個Web服務調用,它返回一個包含50個數據包的消息bean。然後,我把它放到我的SQLite以下方式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個數據包插入表中。
我不是100%確定,但您可能需要將dashboardCustomer中的屬性標記爲列。 –