Visual C# | Grouping using LINQ exercise | Group directors by their birth year using LINQ query expressions

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 ==> Average difficulty
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:

  1. Go into SQL Server Management Studio.
  2. Open the file with the SQL extension in the above folder.
  3. Run this to create the Movies database.

Now use the Object/Relational designer to create a new LINQ to SQL classes item data context model:

Movies data model

No need to rename any entities or properties ...


Create a form called frmFilmDirectorsByBirthYear, and within this create code to display directors grouped by their year of birth, excluding anyone born before 1950:

The directors by year of birth

The start of the output from your code.


You'll need to convert the DirectorDOB property in the model to DateTime format before you can access its Year property.

Close down any open windows!

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