Link to home
Start Free TrialLog in
Avatar of quentinA
quentinAFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Struggling with linq

I haven't got up to speed with linq and need quick fix please.
I have a flat table of bookings i.e. people at certain locations on certain dates.
I would like to use linq to convert into objects that are shown in the image: each instance of the BookingViewModel represents a date, and it has a date, a location and a collection of bookings.
How do I use linq to ?group the flat table by date and location, and then use the result to populate the collection property. All I seem to have access to is the "Key".

I've tried:
 var group =
                    bookingRepository.GetAll().GroupBy(b => b.fkDateTimeObjectId, b=>b.fkLocationId);
Linq-question.png
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of quentinA

ASKER

Thank you both.
Can you recommend a linq book/ training (or should I post this as another question?)
Hi ;

I have used LinqPad which is a free software package for learning and testing Linq queries. The software is free to download and use. They also have a paid option which add autocompletion but only for C# NOT VB .Net.

The software contains many working examples in its library and the website also contains helpful information.

LinqPad

LINQPad standard edition is free to download and use. Autocompletion is an optional extra.
Thanks again! That's great.
Not a problem.