quentinA
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
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()
Linq-question.png
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
Thanks again! That's great.
Not a problem.
ASKER
Can you recommend a linq book/ training (or should I post this as another question?)