public void SetupCommandParameters(DbCommand command, StringBuilder commandText) { for (int i = 0; i < _clauses.Count; i++) { MatchClause clause = _clauses[i]; SQLiteParameter parameter = new SQLiteParameter("@" + clause.FieldName, clause.Value); if (i != 0 && clause.Operation != MatchClause.OperationEnum.NA) { if (clause.Operation == MatchClause.OperationEnum.AND) { commandText.Append(" AND "); } else if (clause.Operation == MatchClause.OperationEnum.OR) { commandText.Append(" OR "); } } commandText.Append(" (" + clause.FieldName + " = " + parameter.ParameterName + ")"); command.Parameters.Add(parameter); } }
/// <summary> /// Single clause expression /// </summary> public MatchExpression(string fieldName, object value) { MatchClause clause = new MatchClause(MatchClause.OperationEnum.NA, fieldName, value); _clauses.Add(clause); }