[odb-users] Is that possible to order the child objects based on
some specific column
Boris Kolpackov
boris at codesynthesis.com
Fri Nov 1 11:12:36 EDT 2019
不明真相 <icewill9999 at vip.qq.com> writes:
> Say i have two tables, A and B of 1:N relationship, B is eager loaded.
>
>
> #pragma db object
> class A
> {
> ........
> vector<weak_ptr<B>> b_;
>
> }
>
>
> class B
> {
> .......
> int column_C;
> }
>
>
> i want the B objects was ordered by column_C in the vector. Is that
> possible to do that? i use odb 2.4.0.
There is no built-in support at the ODB level for this. You can check
if it's possible at the database level for the database that you use
(i.e., some kind of a default sort order). Alternatively, you can use
an ODB view (probably an object-loading view) with an ORDER BY clause
to manually load the vector (say from a database callback).
More information about the odb-users
mailing list