Linq "group join query" not working

Hello everyone,

I’m trying to join two datatables with a group join linq query. All works fine, with a small dataset, where there are no empty cells in the table. As soon as I have an empty cell, the query fails, because the datarow at the end is empty.
Can you please tell me what I’m doing wrong?

The query is:

(From date_amotiq In amotiq_data_dt.AsEnumerable Group Join v05_va33_data In v05_join_va33_zalvunloading.AsEnumerable On date_amotiq(“MATNR”).ToString Equals v05_va33_data(“ALV_PN”).ToString And date_amotiq(“KDMAT”).ToString Equals v05_va33_data(“CUST_PN”).ToString And date_amotiq(“UIP_Formatted”).ToString Equals v05_va33_data(“Unloading_Point”).ToString Into main_sht_data = Group From v05_va33_data in main_sht_data.DefaultIfEmpty() Select main_sheet_dt.Clone.LoadDataRow(New Object() {“RO1W”, date_amotiq(“MATNR”), date_amotiq(“KDMAT”),date_amotiq(“UIP_Formatted”), date_amotiq(“RDATUM”), “”, main_sht_data.ElementAtOrDefault(0).Item(0)},False)).CopyToDataTable

The issue of the query is the following part “main_sht_data.ElementAtOrDefault(0).Item(0)” which does return correct data, if there is something to return, and crashes if not. The expression above is considered to be a datarow.

Thank you,
Razvan