I am building a query builder that works pretty well except I can’t figure out how to group the filters together by column to get something like: where (col1=1 or col1=2) and (col2=5 and col2=3). What I have is something like the following code. Everytime there is a traversal it means there is a new set of filters for a column that need to be grouped but I can’t figure out how to coax the expression to add the parenthesis?

```
public static GridFilterSet TraverseWhere<T>(GridFilterSet filterSet, SqlExpression<T> exp, ref int pCount)
{
if (filterSet != null)
{
foreach (var f in filterSet.Filters)
{
if (f.IsFilter())
{
CreateWhere(exp, filterSet.Logic, f, ref pCount);
}
else
{
TraverseWhere<T>(f, exp, ref pCount);
}
}
}
return filterSet;
}
public static void CreateWhere<T>(SqlExpression<T> exp, string Operator, GridFilter filter, ref int pCount)
{
if (Operator.ToUpper() == "AND")
{
exp.Where(filter.TranslateOperatorToSql(pCount), filter.Value);
}
else
{
exp.Or(filter.TranslateOperatorToSql(pCount), filter.Value);
}
pCount++;
}
```