How to retrieve one table row and list of rows that are connected to the first row in Linq .NET

Viewed 64

I have specific problem. I'm not too experienced with SQL so this may be a silly question. I have the following class

class StructuredResult
{
    public Pay Pay{ get; set; }
    public Processing Processing{ get; set; }
    public Member Member { get; set; }

    public StructuredResult()
    {
    }
}

And this is the code I'm getting this with

var allPaying = (from pay in Entities.Pays
                join prc in Entities.Processingss on pay.IDCalculation equals cal.IDCalculation
                join mbr in Entities.Members on pay.IDMember equals mbr.IDMember

                where pay.IDMember == IDMember
                orderby prc.DateFrom descending
                select new StructuredResult()
                {
                    Pay = pay,
                    Processing = prc,
                    Member = mbr
                }).ToList();

The code is working fine I changed things for posting here, maybe some name changes are not ok. What I need to get is this:

class StructuredResult
{
    public Pay Pay{ get; set; }
    public Processing Processing{ get; set; }
    public Member Member { get; set; }
    public List<PayDetail> PayDetails { get; set; }

    public StructuredResult()
    {
    }
}

Does anyone know if this is even possible? Pay detail is connected with Pay.ID = PayDetail.ID Thanks in advance

2 Answers
Related