Queries: order by property of related entity
See original GitHub issueis possible to sort parent items by child property ?
for example :
Author
- name
- birthday
Birthday
- date
i want list all authors, but when birthday != null
must be sorting first
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
How to order by with related entity properties in EF core
u want order by Locality ASC,right? I think Class type of query is IEnumerable,so you can use lumbda expression.
Read more >Loading Related Entities - EF6 - Microsoft Learn
Eager loading is the process whereby a query for one type of entity also loads related entities as part of the query.
Read more >JS | Query Examples - Breeze
Single property sorting; Multiple property sorting; Related property sorting. Paging with 'skip' and 'take' ... Query by key; Query a bag of entities...
Read more >[Solved]-Sort entities based on a substring-Entity Framework
Related Query · Sort entities based on a substring · LINQ to Entities Sort Expression based on client input · How to query...
Read more >Entity queries | Apple Developer Documentation
Help the system find the entities your app defines and use them to resolve ... Details about a specific property you use to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@smith6k If you are asking about the equivalent of a JOIN: yes this is planned soon-ish.
For those who are interested, here’s the workaround I finally came up with. It doesn’t implement the ability of
LiveData
to update datasets as they change, but it works correctly withPagedList
, which is an okay tradeoff in my very own case.Goal
Produce a
LiveData<PagedList<Content>>
ordered byGroupItem.order
, whereContent
has a N…1 relationship withGroupItem
.In ObjectBox terms, the data model is as follows :
public ToOne<Content> content;
@Backlink(to = "content") public ToMany<GroupItem> groupItems;
Vanilla way of implementing (does not work when ordering with
GroupItem.order
for the reasons stated in this issue)Query<Content>
LivePagedListBuilder<>(new ObjectBoxDataSource.Factory<>(Query<Content>), cfg).build()
Workaround
Query<GroupItem>
query.order(GroupItem_.order)
query.link(GroupItem_.content)
to apply whatever filter should be applied toContent
Content
ID’s withStream.of(query.build().find()).map(gi -> gi.content.getTargetId()).toList()
ObjectBoxPredeterminedDataSource
(custom class; see code below) that will produce yourLiveData<PagedList<Content>>
.This DataSource is fed with :
Function<List<Long>, List<I>>
that will be used to fetch your objects in the DB. In my case, the fetcher is a good oldstore.boxFor(Content.class).get(idList)
My implementation of
ObjectBoxPredeterminedDataSource
is inspired byObjectBoxDataSource
: https://gist.github.com/RobbWatershed/d6360f797d33e63606f2902b7621bf6c