I am currently getting a distinct list of data. Properties are MDMMappingCode which is unique and CustNameReporting which can have duplicate data.
Data being returned:
From my linq query the data being returned is correct but I only need 1 unique CustNameReporting instead of 5 being repeated. This issue I am facing is the MDMMappingCode is different. What should I change in my linq query to take the first record.
Code
List<OptionDto> customers = await _appDbContext.MasterDataCustomerActivityGrids
.Select(e => new OptionDto() { Value = e.MDMMappingCode, Label = e.CustNameReporting })
.Distinct()
.OrderBy(e => e.Label)
.ToListAsync(cancellationToken);
public class OptionDto
{
public string Value { get; set; }
public string Label { get; set; }
}