Home > Net >  How to Find the record with same date in an array inside a list
How to Find the record with same date in an array inside a list

Time:08-16

Please help me to get records from array 'attachment' having same date as that of list 'event' (in example records with attachment id=42). If two records in attachment is having same date then record with highest attachment id is need to be selected. Here Event is a list
Fig1

So that the final result should be like this.

Fig2

I tried as following, but it doesn't work

Fig3

CodePudding user response:

                dataEvents = dataEvents.Select(e =>
                {
                    e.Item.Entity.Attachments = new Attachments[] 
                            { (e.Item.Entity.Attachments.Where(x => x.ActualDate==e.ActualDate).OrderByDescending(p => p.Id).FirstOrDefault()) };
                    return e;
                });
  • Related