servicestackormlite-servicestack

Does OrmLite's SelectMulti work with more than 7 tables?


I am using ServiceStack 8.2.2, c# and .net8 with postgres 16. I'm trying to use OrmLite's SelectMultiAsync with more than 7 tables.

If I specify a type for the last table, i.e.

var results = await Db.SelectMultiAsync<T1, T2, T3, T4, T5, T6, T7, T8>(query);

I get an error "The last element of an eight element tuple must be a Tuple.".

If I then specify a tuple as the last element, i.e.

var results = await Db.SelectMultiAsync<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>>(query);

I get an error "42P01: missing FROM-clause entry for table "tuple_`1"".

If I specify the tables I want to select in the SelectMulti, i.e.

var results = await Db.SelectMultiAsync<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>>(query,
[
$"{Db.GetQuotedTableName<T1>()}.*",
$"{Db.GetQuotedTableName<T2>()}.*",
$"{Db.GetQuotedTableName<T3>()}.*",
$"{Db.GetQuotedTableName<T4>()}.*",
$"{Db.GetQuotedTableName<T5>()}.*",
$"{Db.GetQuotedTableName<T6>()}.*",
$"{Db.GetQuotedTableName<T7>()}.*",
$"{Db.GetQuotedTableName<T8>()}.*"
]);

the query runs, but Rest.Item1 (which should contain table T8) is null. This is despite the fact that T8 is part of an inner join and the query returns fine if I don't try to get the value of T8. Is there a trick to this, or is it a bug?

It's not a showstopper since there are other ways I can get this data, but it would be nice to not have to work around it.


Solution

  • Unfortunately this is a limitation of the .NET Tuple classes which has a maximum of 8 generic arguments, but the 8 parameter Tuple restricts the last element to be a Tuple itself which is incompatible with OrmLite Data Models:

      public class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> : 
        IStructuralComparable,
        IStructuralEquatable,
        IComparable,
        ITuple
        where TRest : notnull
    

    So currently OrmLite doesn't support it, we'll look into whether it can be made to support it or whether to limit the APIs to 7 tables.