Let’s look over the following code:
The cause of this problem is not from the order function. This is a core function of .NET that works perfect.
The ordering is not made on the both blocks of the IF. Because in general the list were already ordered in database and the clients usually didn’t reach the ELSE block of the code, these case appear very rarely.
public List<Result> SomeFunction(string machineId)
{
...
if(machineId == null)
{
...
List<Result> results = GetAllResults();
return results.OrderByDescending(x => x.Date);
}
else
{
...
return GetResultsByMachine(machineId);
}
}
In production there was a bug reported by client. From time to time, clients received elements in wrong order.The cause of this problem is not from the order function. This is a core function of .NET that works perfect.
The ordering is not made on the both blocks of the IF. Because in general the list were already ordered in database and the clients usually didn’t reach the ELSE block of the code, these case appear very rarely.
public List<Result> SomeFunction(string machineId)
{
...
List<Result> results
if(machineId == null)
{
...
results = GetAllResults();
}
else
{
...
results = GetResultsByMachine(machineId);
}
return results.OrderByDescending(x => x.Date);
}
This is a small detail that can generate odd behavior on the client machines.
Comments
Post a Comment