0

I used a join for a simple database in LinqToSQL and want to show the result in a DataGridView. When I use the code below, it shows the types of the columns, not columns or values. How should I use it to show all columns correctly?

public void RefreshDGV()
 {
     dataGridView1.DataSource = SQLHelper.otdc.StandartProds
          .Join(SQLHelper.otdc.Orders, a1 => a1.OrderID, a2 => a2.OrderID, (a3, a4) => new { a3, a4 })
          .Join(SQLHelper.otdc.Colors, b1 => b1.a3.ColorID, b2 => b2.ColorID, (b3, b4) => new { b3, b4 })
          .Select(x => x);
}

The result image:

enter image description here

Ali Tor
  • 2,772
  • 2
  • 27
  • 58
  • possible duplicate of [What is the syntax for an inner join in LINQ to SQL?](https://stackoverflow.com/questions/37324/what-is-the-syntax-for-an-inner-join-in-linq-to-sql). You need to select a new object with the values you want – jeubank12 Dec 12 '17 at 21:51
  • `.Select(x => x)` actually does nothing in this context - you need to create an anonymous object containing the fields you need. The form of `x` in the `Select` is `new { b3 = new { a3, a4 }, b4 }` which isn't likely to be what you want. – NetMage Dec 13 '17 at 00:32
  • Should I write all columns clearly in the SELECT command even I want to show all columns with no exception? (btw there is 10 columns and it can be more) – Ali Tor Dec 13 '17 at 14:32

0 Answers0