Accepted answer

If you need all rows from first table whether or not they can be joined to rows from second table, you need a left join:

    var results = from table1 in table.AsEnumerable()
                  join table2 in comment.AsEnumerable()
                  on table1.Field<string>("KundeName") equals table2.Field<string>("KundeName") into joined
                  from table3 in joined.DefaultIfEmpty()
                  select new
                          KundeID = table1.Field<Int32?>("KundeID"),
                          KundeName = table1.Field<String>("KundeName"),
                          Produkt = table1.Field<String>("Produkt"),

                          Comment = table3 != null ? table3.Field<String>("Comment") : null

This way you can get client named "Miky" but the Comment for him is going to be null.


Your o4 object doesn't have an object in comment that has a matching KundeName value, so it is not included in the results.

Perhaps you did not mean to use an inner join?

Related Articles