C# Linq Join Into语句编辑器错误

C# Linq Join Into statement editor error

var joinedTables =  from tableRow in filteredTable.AsEnumerable()
                    join contactsRow in contacts.AsEnumerable()
                    on tableRow.Field<double>("Opportunity: Store Number") equals contactsRow.Field<double>("National Store .")
                    into lj
                    from r in lj.DefaultIfEmpty()
                    select resultTable.LoadDataRow(new object[]
                    {
                        tableRow.Field<double>("Opportunity: Store Number"),
                        tableRow.Field<DateTime>("Target Circuit Completion (FOC)"),
                        tableRow.Field<string>("Vendor Name"),
                        contactsRow.Field<string>("Contacts - ACM - Email")
                    }, false);

我正在尝试使用 this answer. However when I try to add fields from contactsRow into the object array argument of the .LoadDataRow() function, the editor says 'contactsRow' does not exist in the current context. How is my code different from the answer in my link? I have been really trying to learn LineQ to avoid crazy-nested loops but this has me stumped. More code here.

使用 LinQ 在两个表上执行左外连接

编辑:

var joinedTables =  from tableRow in filteredTable.AsEnumerable()
                            join contactsRow in contacts.AsEnumerable()
                            on tableRow.Field<double>("Opportunity: Store Number") equals contactsRow.Field<double>("National Store .")
                            into lj
                            from r in lj.DefaultIfEmpty()
                            select resultTable.LoadDataRow(new object[]
                            {
                                tableRow.Field<double>("Opportunity: Store Number"),
                                tableRow.Field<DateTime>("Target Circuit Completion (FOC)"),
                                tableRow.Field<string>("Vendor Name"),
                                r.Field<string>("Contacts - ACM - Email"),
                                r.Field<string>("OO - Ops Mgr Name"),
                                r.Field<string>("Contacts - Area Sup / BC - Email"),
                                r.Field<string>("Contacts - OTP - Email"),
                                r.Field<string>("OTM Email Address")
                            }, false);
        return resultTable;

我按照建议在 select 语句中将代码从 resultTable 更改为 r。代码现在可以编译,但是 resultTable 是空的。

您需要 select 来自 r 而不是来自 contactsRow。