How to work around ServiceStack OrmLite's limit of seven joined tables

Viewed 66

Using ServiceStack OrmLite (5.1.0), we need to run a query that brings in 8 joined tables (it's a product table - we need to pull in the product and all related data about its category, brand, supplier, and so on).

OrmLite provides, for example SqlExpression.Select<T1, T2, T3, T4, T5, T6, T7>(), but that's one too few tables. The same limitation looks to extend to all query methods - eg, IDbConnection.SelectMultiAsync<T1, T2, T3, T4, T5, T6, T7>().

We could potentially run two queries and join the data in code, but is there a workaround using OrmLite that keeps it to one joined query?

(I know we should upgrade, and it would be good to know if this limitation is or isn't lifted in later versions, but for now I'm looking for a way to solve this under 5.1)

1 Answers

The latest v5.12 of OrmLite now supports 12 tables in its SqlExpression.Select<> APIs.

SelectMultiAsync returns a generc .NET Tuple<> which has a maximum of 8 generic args, which I've just added support for in this commit which should be available on NuGet within the next 2 days.

Related