I have a function that returns SqlExpressionVisitor to be used later as an input to Select statements.
private SqlExpressionVisitor<Account> GetExpressionVisitor (int id, bool detailed, SqlExpressionVisitor<Account> ev)
{
if (!detailed)
{
ev = ev.Where (a => a.Id == id);
}
else
{
// need to do join with another table via JoinSqlBuilder to query more information and then pack results in the ev object ...
}
return ev;
}
Any idea how to convert JoinSqlBuilder to SqlExpressionVisitor or how to edit SqlExpressionVisitor and inject the join query in an effective way?
It's not clear exactly what you're trying to achieve but you can add use the Typed API for Joins similar to your typed Where
expression. Otherwise if using a Typed API isn't possible you can use the CustomJoin API to add a string JOIN expression to your query, e.g:
var q = Db.From<Job>();
q.CustomJoin($"LEFT JOIN (SELECT {nameof(Job.Id)} ...")