2016-10-14 61 views
0

我想最後得到插入我的查詢的ID此如何獲得最後插入sqlite的ID xamarin形成

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

插入查詢後,只需使用SQLite last_insert_rowid()函數來獲得剛生成的SQLite的自動增量字段的值:

select last_insert_rowid(); 
相關問題