I'm trying to get back a list of TransferIds, for each transfer a list of ChargeIds, and for each of those a list of ReferralMatches
here is what I've got
(from c in Commissions
where c.TransferStatus == "Paid"
where c.AdminHasReleased == false
join r in ReferralMatches on c.ReferralMatchId equals r.ReferralMatchId
group c by new { c.TransferId } into grp
select new {
TransferId = grp.Key.TransferId,
Charges = from c in grp
group c by c.ChargeId into grp2
select new {
ChargeId = grp2.Key,
Referrals = grp2 }
})
This works and is very close. It pulls back something that looks like this:

This looks like Charges that belong to a TransferId but what I need is ReferralMatches that belong to Charges that belong to a transferId. I've tried another select to pull in 'r' but running into errors.
I think LINQ people will be able to gather what they need from this post but if more info is needed, kindly let me know. Thank you.
EDIT, adding table samples
The two expanded tables are what I have to work with. It probably isn't useful but keep in mind that the ReferralMatch table also has ChargeId. One chargeId can cover multiple ReferralMatches but once the funds are available a bank transfer occurs...when that happens, records are created in the Commissions table.
So what I'm looking for is a list of TransferIds, foreach Id a list of chargeIds, and foreach chargeId a list of ReferralMatches...the innermost list of ReferralMatches would be full records from that table.

EDIT, more attempts
here's my latest attempt
from c in Commissions
where c.TransferStatus == "paid"
group c by c.TransferId into transferGroup
select new {
TransferId = transferGroup.Key,
Charges = from c in transferGroup
join r in ReferralMatches on c.ReferralMatchId equals r.ReferralMatchId
group c by c.ChargeId into chargeGroup
select new {
ChargeId = chargeGroup.Key,
Referrals = from r in chargeGroup
select new {
Referral = r
}
}
}
which pulls up something like this:

but unless I'm reading this incorrectly, the innermost item is still commission table which doesn't make sense. I need that to be ReferralMatches that have a ChargeId of [whatever]