Code:
public IList<TestGridModel> GetRecords()
{
return _TestRepository.GetAll()
.Select(x => new TestGridModel
{
IdName = x.IdName,
LName = x.LastName,
FName = x.FirstName,
IdRecord = x.RecordId,
LastModifiedDate = x.LMDate
}).ToList();
}
I need to change the above query based on the following condition.
I want to fetch the records of recent modified
date(LastModifiedDate) with distinct of IdRecords(IdRecord).
Note: Record Id may be duplicate, but I need to get the records with recent modified date with distinct of record ids.
You can use
GroupByand then take first item from the group order by modified date.