Visual C# | Grouping using LINQ exercise | Use LINQ to SQL to group films by studio, and reorder

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Software ==> Visual C#  (79 exercises)
Version ==> Any version of C#
Topic ==> Grouping using LINQ  (2 exercises)
Level ==> Harder than average
Subject ==> C# training
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

If you haven't already done so, run the script in the above folder in SSMS to generate the Movies database, and create some suitable LINQ to SQL classes model.

Create a new form called frmStudios.  Within this write code using the LINQ group operator to summarise the films by studio (use Skip to miss out the first one, though, as this is 20th Century Fox which swamps everything else):

List of films by studio

The start of the output from your code.


Too easy?  Change the sort order of the studios by grouping them into another enumerable set, and selecting that as the output from your query expression:

Studios in reverse order

This time we're skipping the first 5 studios, as this will miss out behemoths like Warner Brothers and Walt Disney.


Close down any files that you have open.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post