It’s really hard to answer without the full context, but I’ll try to guide you through how to solve this problem.
The first thing to do would be to remove the DbFunctions.TruncateTime(c.DataBaixa)
. They seem unnecessary. If you do not want to take into account the time, your search should be by the date with the times at 00:00 and 23:59:59. The same for the OrderBy
, unless it is strictly necessary that his return be ordered by the date, ignoring the time, and then by another property (such as the name of the company), but still could follow a different approach, if any (it does not seem to be, given his attempt with ThenBy(c => c.ID_EmpresaConta)
). Also change the report display to include the time, to make it easier to understand the problem. This will not solve your problem yet, but should improve your query and facilitate data visualization.
Before trying to see the problem in the report, see the values in lista
. I imagine there are four entrances to Empresa2XYZ
. To make sure these entries are together in your result .OrderBy(c => DbFunctions.TruncateTime(c.DataBaixa)).ThenBy(c => c.ID_EmpresaConta).ToList();
should actually solve the problem, but without having the full context of your data and data model, I can’t figure out why it doesn’t work. Again this still doesn’t solve the problem, but it helps you try to identify it.
Finally, in order to ensure that the resolutions are grouped together, you could use the GroupBy
and group by date (without time in this case) and ID
or nome
of the company. This can be done so .GroupBy(x => new { x.Column1, x.Column2 })
, where Column1
would be your date, no time, and Column2
a unique identifier for enterprises.
managed to come to some conclusion?
– tvdias
I suggest you improve the description of the problem by explaining the context. The report should not also be ordered by company?
– José Diz