I have a list of custom classes below.
protected class Ringing
{
public int Id { get; set; }
public int Rssi { get; set; }
public byte[] MacAddress { get; set; }
}
private List<Ringing> Ringings { get; set; } = new List<Ringing>();
Then, I put in the data.
Ringings.Add(new Ringing
{
Id = 2,
Rssi = 1,
MacAddress = new byte[] { 0x12, 0x34 },
});
Ringings.Add(new Ringing
{
Id = 3,
Rssi = 2,
MacAddress = new byte[] { 0x12, 0x34 },
});
Ringings.Add(new Ringing
{
Id = 4,
Rssi = 4,
MacAddress = new byte[] { 0x56, 0x78 },
});
Ringings.Add(new Ringing
{
Id = 2,
Rssi = 10,
MacAddress = new byte[] { 0x56, 0x78 },
});
Here, I want to leave only one object with the lowest RSSI value per MAC address. The expected result is:
Id = 2, Rssi = 1, MacAddress = { 0x12, 0x34 },
Id = 4, Rssi = 4, MacAddress = { 0x56, 0x78 }
How do I query it?