//Select statement public AccountTypeDB GetAccountTypeByName(string name) { string query = "SELECT id as Id, name as Name FROM account_type where name = ?"; AccountTypeDB type = connection.Query<AccountTypeDB>(query, name).First(); if(type == null) { type = new AccountTypeDB(); } return type; }
public List<AccountTypeDB> GetAllAccountTypeForWindow() { string query = "SELECT * FROM account_type where name != 'Address Book' and name != 'Self' and name != 'CSV' and name != 'VCF'"; //Create a list to store the result List<AccountTypeDB> list = new List<AccountTypeDB>(); //Open connection if (this.OpenConnection() == true) { //Create Command SQLiteCommand cmd = new SQLiteCommand(query, connection); //Create a data reader and Execute the command SQLiteDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { int id = Int32.Parse(dataReader["id"].ToString()); string name = dataReader["name"].ToString(); AccountTypeDB type = new AccountTypeDB(); type.Id = id; type.Name = name; list.Add(type); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); } return list; }
public List<AccountTypeDB> GetAccountType() // ttt { List<AccountTypeDB> lists = new List<AccountTypeDB>(); if (this.OpenConnection() == true) { string query = "SELECT * FROM account_type"; //Create Command SQLiteCommand cmd = new SQLiteCommand(query, connection); //Create a data reader and Execute the command SQLiteDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { AccountTypeDB type = new AccountTypeDB(); int id = Int32.Parse(dataReader["id"].ToString()); string name = dataReader["name"].ToString(); type.Id = id; type.Name = name; lists.Add(type); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); } return lists; }
///////////////////////////////// //Select statement public AccountTypeDB GetAccountTypeByName(string name) { AccountTypeDB type = new AccountTypeDB(); if (this.OpenConnection() == true) { string query = "SELECT * FROM account_type where name = @name"; //Create Command SQLiteCommand cmd = new SQLiteCommand(query, connection); cmd.Parameters.AddWithValue("@name", name); //Create a data reader and Execute the command SQLiteDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { int id = Int32.Parse(dataReader["id"].ToString()); type.Id = id; type.Name = name; } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); } return type; }