Is there a way to combine multiple AND's and OR's in OrmLite?

Hi

When building an ISqlExpression I want to be able to combine AND’s and OR’s. I have this query where there is a search on one table of the join OR a search on another table of the join. In SQL

WHERE (table1.Value = 'X' AND (table2.Field1 LIKE '%Y%' OR table2.Field2 LIKE '%Y%')) OR (table1.Value = 'X' AND table3.Field1 = '%Y%')

Is this possible in an expression or do I have to use Raw SQL statement instead?

You can do something like that with:

.Where<Table1,Table2>((t1,t2) => tw.Value == "X" && (t2.Field1.Contains("Y") || t2.Field2.Contains("Y"))
  .Or<Table1,Table2>((t1,t2) => ...);
1 Like