public bool Insert(T t) { try { IDbCommand cmd = connection.CreateCommand(); cmd.Parameters.Clear(); var iq = new InsertQuery(Entity); cmd.CommandType = CommandType.Text; cmd.CommandText = iq.GetQuerywithParameter(t); SetParameter(ref cmd, t); var result = (Int32)cmd.ExecuteNonQuery(); if (result > 0) { return(true); } else { return(false); } } catch (SQLiteException ex) { throw new System.Exception(SQLiteProviderHelper.ErrorHandle(ex)); } }
public int GetLastID(T t) { int result = 0; try { IDbCommand cmd = connection.CreateCommand(); cmd.Parameters.Clear(); var iq = new InsertQuery(Entity); cmd.CommandType = CommandType.Text; cmd.CommandText = iq.GetQuerywithParameter(t) + "; select last_insert_rowid();"; SetParameter(ref cmd, t); result = Convert.ToInt32(cmd.ExecuteScalar()); } catch (SQLiteException ex) { throw new System.Exception(SQLiteProviderHelper.ErrorHandle(ex)); } return(result); }