I have two ILists in my which are getting values from the separate tables within the database. These tables contain the same columns and values but for other reasons the client needs them stored in separate tables.
private IList<MeterReadingDto> _meterReadings;
private IList<PseudoReadingDto> _pseudoReading;
public IList<MeterReadingDto> MeterReadings
{
get
{
return _meterReadings != null ? _meterReadings.OrderByDescending(x => x.ReadDate).ToList() : null;
}
set { _meterReadings = value; }
}
public IList<PseudoReadingDto> PseudoReadings
{
get
{
return _pseudoReading != null ? _pseudoReading.OrderByDescending(x => x.ReadDate).ToList() : null;
}
set { _pseudoReading = value; }
}
As you can see they both get the results and store them, but i now need to merge/union these list so that they can be displayed in one table. Any ideas on how to do this
Consider using the IEnumerable method extension Union.
NOTE: Using this operation will result in duplicate elements between the two collections being removed from the result.