0
0
C Sharp (C#)programming~10 mins

Join and GroupJoin operations in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to join two lists on the Id property.

C Sharp (C#)
var result = from c in customers
             join o in orders on c.Id [1] o.CustomerId
             select new { c.Name, o.OrderId };
Drag options to blanks, or click blank then click option'
A==
Bequals
CequalsTo
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of 'equals' in join clause.
Using incorrect keywords like 'equal' or 'equalsTo'.
2fill in blank
medium

Complete the code to perform a GroupJoin and select the customer name with their orders.

C Sharp (C#)
var result = customers.GroupJoin(orders,
                c => c.Id,
                o => o.CustomerId,
                (c, os) => new { c.Name, Orders = [1] });
Drag options to blanks, or click blank then click option'
Ao
Borders
CorderList
Dos
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original orders list instead of the grouped orders parameter.
Using a variable name not defined in the lambda parameters.
3fill in blank
hard

Fix the error in the join clause by completing the missing keyword.

C Sharp (C#)
var query = from a in authors
            join b in books on a.Id [1] b.AuthorId
            select new { a.Name, b.Title };
Drag options to blanks, or click blank then click option'
Aequals
BequalsTo
CequalTo
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of 'equals'.
Using incorrect keywords like 'equalTo' or 'equalsTo'.
4fill in blank
hard

Fill both blanks to create a dictionary of customer names and their order counts using GroupJoin.

C Sharp (C#)
var customerOrderCounts = customers.GroupJoin(orders,
                            [1],
                            [2],
                            (c, os) => new { c.Name, Count = os.Count() })
                            .ToDictionary(x => x.Name, x => x.Count);
Drag options to blanks, or click blank then click option'
Ac => c.Id
Bo => o.CustomerId
Cc => c.Name
Do => o.Id
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up key selectors by using names instead of Ids.
Using order Id instead of CustomerId for matching.
5fill in blank
hard

Fill all three blanks to join authors and books, then select author name, book title, and year published.

C Sharp (C#)
var joinedData = from a in authors
                 join b in books on a.Id [1] b.AuthorId
                 select new { [2], [3], b.YearPublished };
Drag options to blanks, or click blank then click option'
Aequals
Ba.Name
Cb.Title
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of 'equals' in join.
Selecting wrong properties or missing one.