mk3008 / Carbunql

Carbunql provides query parsing and building functionality.
https://mk3008.github.io/Carbunql/
MIT License
40 stars 3 forks source link

[Experiment] TypeSafe Query Builder - Omitting table join expressions #427

Open mk3008 opened 1 month ago

mk3008 commented 1 month ago

We would like to be able to omit the table join if the join expression is defined in the model class.

Currently, this kind of writing is necessary.

var query = Sql.From(() => od)
                .InnerJoin(() => o, () => o.order_id == od.order_id)

If the join expression is defined in the model class, it should be possible to write it as shown below.

var query = Sql.From(() => od)
                .InnerJoin(() => o)

Note that if there are multiple table joins (for example, creator and updater), this method cannot be used and a runtime error will occur.

Also, if you do not want to use the join expression defined in the model class, you should be able to avoid this by defining it manually. (Previous specifications)