Error encountered on Linq Group Join

This is my code on matching 2 datatables it says first_filter is not declared or not in current scope.

The goal here is if transaction match using Trans ID and af_short_trans_id let BbReport = Yes and if not check af_servic_type=“revoke”, af_order_status=“success”, acctng_direction=“c” before adding no

Hey @joscares

Please paste the query here !

Thanks
#nK

(
From float_send In dt_floatSend
Group Join first_filter In dt_ballooningFirstFilterDetails
On float_send(“Trans ID”).ToString Equals first_filter(“af_short_trans_id”).ToString Into grp = Group
From g In grp.DefaultIfEmpty
Let CRemarks = float_send(“Remarks”).ToString
Let Date1 = float_send(“Date”).ToString
Let TransID = float_send(“Trans ID”).ToString
Let Core = float_send(“Core Trans ID”).ToString
Let MSISDN = float_send(“MSISDN”).ToString
Let Type = float_send(“Type”).ToString
Let Channel = float_send(“Channel”).ToString
Let State = float_send(“State”).ToString
Let Amount = float_send(“Amount”).ToString
Let Target = float_send(“Target”).ToString
Let LongTransID = float_send(“Long Trans ID”).ToString
Let Invno = float_send(“Invoice No.”).ToString
Let RevDate = If(float_send(“Rev Date”).ToString = “-2146826246”,“#N/A”, float_send(“Rev Date”).ToString)
Let RevTransID = float_send(“Rev TransID”).ToString
Let Remarks = float_send(“Remarks”).ToString
Let TransDate = float_send(“TransDate”).ToString
Let Time = float_send(“Time”).ToString
Let NextDayReversal = float_send(“NEXT DAY REVERSAL”).ToString
Let SuccessfulNextDay = float_send(“SUCCESSFUL NEXT DAY”).ToString
Let StatusinMC = float_send(“STATUS IN MC”).ToString
Let af_servic_type = first_filter(“af_servic_type”).ToString
Let af_order_status = first_filter(“af_order_status”).ToString
Let acctng_direction = first_filter(“acctng_direction”).ToString
Let InternalTransfer = String.Empty
Let BbReport = If(IsNothing(g) And (af_servic_type=“REVOKE” Or af_servic_type=“revoke”) And (af_order_status=“SUCCESS” Or af_order_status=“success”) And (acctng_direction=“C” Or acctng_direction=“c”) ,“NO”,“YES”)
Let ExternalWIthdraw = String.Empty
Let Fee = float_send(“FEE”).ToString
Select dt_ManualReversalOutput.Rows.Add(CRemarks, Date1, TransID, Core, MSISDN, Type, Channel, State, Amount, Target, LongTransID, Invno, RevDate, RevTransID, Remarks, TransDate, Time, NextDayReversal, SuccessfulNextDay, StatusinMC, BbReport, InternalTransfer, ExternalWIthdraw, Fee)
).CopyToDatatable

dt_ManualReversalOutput.Rows.Add({CRemarks, Date1, TransID, Core, MSISDN, Type, Channel, State, Amount, Target, LongTransID, Invno, RevDate, RevTransID, Remarks, TransDate, Time, NextDayReversal, SuccessfulNextDay, StatusinMC, BbReport, InternalTransfer, ExternalWIthdraw, Fee})

Rows.Add will accept only Object Array

Still same error this is the line if code where the error happens

Let af_servic_type = first_filter(“af_servic_type”).ToString
Let af_order_status = first_filter(“af_order_status”).ToString
Let acctng_direction = first_filter(“acctng_direction”).ToString

@joscares ,

Could you change the first_filter to g and Check if it works ?

The Statements are under the Second Iteration where g is the iterative object to be used.

Hey @joscares

Yes I can understand but just checking overall

So now that is a compile time error right ?

I guess you missing the AsEnumerable as mentioned below,

dt_floatSend.AsEnumerable()
dt_ballooningFirstFilterDetails.AsEnumerable()

Thanks
#nK

I tried but it says that columns is not existing

Hey @joscares

Please try adding AsEnumerable Thanks

#nK

@joscares ,

Are the above Columns present in both the Datatables dt_floatSend and dt_ballooningFirstFilterDetails ?

Do not ommit the AsEnumerable()

From float_send In dt_floatSend.AsEnumerable()

First_filter In dt_ballooningFirstFilterDetails.AsEnumerable()

After Group Joining first_filter is not longer valid / accessible, so g will reflect the current right side row

In general we can also make more compact the rowArray construction by using colname lists

1 Like