public List <Models.DisplayItem> GetItemsByStr(string str) { string sql = "SELECT TableId, Title, Description, Date FROM Todo " + "WHERE Title LIKE ? OR Description LIKE ? OR Date LIKE ?"; int i, searchKeyNum = 3; using (var statement = conn.Prepare(sql)) { for (i = 1; i <= searchKeyNum; ++i) { statement.Bind(i, "%" + str + "%"); } List <Models.DisplayItem> res = new List <Models.DisplayItem>(); Models.DisplayItem tmp; while (statement.Step() == SQLiteResult.ROW) { // get result of one row tmp = new Models.DisplayItem() { Id = (Int64)statement[0], Title = (string)statement[1], Description = (string)statement[2], Date = (string)statement[3] }; res.Add(tmp); } return(res); } }
public List <Models.DisplayItem> GetAllItems() { string sql = "SELECT * FROM Todo"; using (var statement = conn.Prepare(sql)) { List <Models.DisplayItem> res = new List <Models.DisplayItem>(); if (res.Count > 0) { } Models.DisplayItem tmp; while (statement.Step() == SQLiteResult.ROW) { // get result of one row tmp = new Models.DisplayItem() { Id = (Int64)statement[0], Title = (string)statement[1], Description = (string)statement[2], Date = (string)statement[3] }; res.Add(tmp); } return(res); } }