I have a SqlExpression<T1>, that joins T1 and T2 and extract some data from both of them.
If I wanted to use that to update some record of T1, I can do the following:
_db.UpdateOnly(() => new T1{ Field= "foo" }, q); // q is my SqlExpression
I can’t do that for T2 tho:
_db.UpdateOnly(() => new T2{ Field= "foo" }, q);
In the second case the generic type is wrong, since the query is SqlExpression but updateFields is of type T2.
Can I change the type of the SqlExpression? Or can you make an Update[Only][Async] overload that accept IUntypedSqlExpression or ISqlExpression?
No you can’t change the source table type of the SqlExpression.
I’ve just added overloads accepting a SQL whereExpression and DB params in this commit which you can access from a typed SqlExpression<T> using q.WhereExpression and q.Params.
I’m not adding overloads for the proposed unintuitive and niche API, the API added lets you use any custom Where expression and db params.
Have you tried calling it using q.WhereExpression and q.Params as I’ve suggested? It extracts the WhereExpression and DB Params the same as what’s used when passing in SqlExpression<T>.
If it doesn’t do what you need you’d need to re-create the expression using the alternative table you want.