我想获得我的查询的最后插入ID
public IEnumerable<DraftOrderInfoTable> SaveDraftOrderInfo(int orderno, int customerid, string customername, string customeremail, string orderdate)
{
var draftorderinfo = new DraftOrderInfoTable
{
OrderNo = orderno,
CustomerId = customerid,
CustomerName = customername,
CustomerEmail = customeremail,
OrderDate = orderdate,
};
_connection.Insert(draftorderinfo);
}
请告诉我如何获取最后插入的ID?
答案 0 :(得分:0)
在插入查询之后,只需使用SQLite last_insert_rowid()函数来获取刚刚生成的SQLite自动增量字段的值:
select last_insert_rowid();