To join two or more collections using LINQ query syntax in C#, you can use the join keyword followed by the on keyword to specify the join condition. Here's an example that joins two collections based on a common property:
main.cs675 chars23 lines
In this example, the join keyword is used to join the customers and orders collections based on the Id and CustomerId properties, respectively. The resulting collection consists of anonymous objects with the CustomerName and OrderTotal properties. By using select new you can select what you want to show up in the results. This will only show the Customer name and the Order total, but you can adjust it to your liking.
Note that you can join more than two collections by chaining additional join statements together.
gistlibby LogSnag