private void initSelectQuery() { _selectCommand = new DbCommandHelper(_connection); string fieldList = ""; for (int i = 0; i < _allProperties.Count; i++) { fieldList += "[" + _allProperties[i].Name + "]"; if (i < _allProperties.Count - 1) { fieldList += ", "; } } _selectCommand.AddParameter("@id"); string query = string.Format("SELECT {0} FROM [{1}] WHERE id = @id", fieldList, _tableName); _selectCommand.Command.CommandText = query; }
private void initInsertQuery() { _insertCommand = new DbCommandHelper(_connection); string fieldList = ""; string paramList = ""; for (int i = 0; i < _subsetProperties.Count; i++) { fieldList += "[" + _subsetProperties[i].Name + "]"; paramList += "@" + _subsetProperties[i].Name; if (i < _subsetProperties.Count - 1) { fieldList += ", "; paramList += ", "; } _insertCommand.AddParameter("@" + _subsetProperties[i].Name); } string query = string.Format("INSERT INTO [{0}] ({1}) VALUES ({2})", _tableName, fieldList, paramList); _insertCommand.Command.CommandText = query; }
private void initUpdateQuery() { _updateCommand = new DbCommandHelper(_connection); string paramList = ""; for (int i = 0; i < _subsetProperties.Count; i++) { paramList += "[" + _subsetProperties[i].Name + "] = @" + _subsetProperties[i].Name; if (i < _subsetProperties.Count - 1) { paramList += ", "; } _updateCommand.AddParameter("@" + _subsetProperties[i].Name); } _updateCommand.AddParameter("@id"); string query = string.Format("UPDATE [{0}] SET {1} WHERE [id] = @id", _tableName, paramList); _updateCommand.Command.CommandText = query; }
private void initDeleteQuery() { _deleteCommand = new DbCommandHelper(_connection); _deleteCommand.Command.CommandText = string.Format("DELETE FROM [{0}] WHERE [id] = @id", _tableName); _deleteCommand.AddParameter("@id"); }