How can i let two simple list join

28 views
Skip to first unread message

Summer chen

unread,
May 28, 2024, 11:06:02 PM5/28/24
to Jinq
Hi,

I have two  simple lists,List<Flight> flights , List<TripRecord> trips. The joining addition is Flight.flightNo ==  TripRecord.flightNo &&  Flight.departTime ==  TripRecord.departTime.

It should be noted that the Flight attribute is not included in entity TripRecord

How can I use Jinq to make flights join trips?

Thanks very much for your time!


Jinq

unread,
May 28, 2024, 11:14:12 PM5/28/24
to Jinq
Sure, you can just use the join() command: https://www.jinq.org/docs/queries.html#N66691

You probably need to use the example from the very end of the section of the documentation about join():

flightStream.join( (f, source) -> source.stream(TripRecord.class) );

This creates a stream of <Flight, TripRecord> pairs. And then you can filter those pairs to only those with matching flight numbers and departure times.

Note: I'm assuming that you're not actually using simple lists and that you're actually accessing data from a database. If you simply have simple lists, then you would not really use Jinq for that.

Reply all
Reply to author
Forward
0 new messages