Answer the question
In order to leave comments, you need to log in
How to speed up a LINQ query?
There was a problem from where I did not expect ...
Here is such a monster I got with my knowledge:
data - IEnumerable T for about 400 elements.
LogicalName - byte array
var result = (from gdt in groupedDataTime
join ad in activeDevices
on gdt.Key.DeviceId equals ad.DevId
join a in addresses
on ad.GAID equals a.GAID
select new DeviceDto()
{
Id = (int)ad.DevId,
SerialNo = ad.SerialNo,
Address = a.UnitName,
DevTypeId = ad.DevTypeId,
SubType1 = ad.SubType1,
SubType2 = ad.SubType2,
DateInstall = ad.DateInstall,
GroupId = ad.GroupId,
Time = gdt.Key.Time
}).ToList();
var count = result.Count();
for (var i = 0; i < count; i++)
{
result[i].Total = data.Where(x => x.DeviceId == result[i].Id && x.Time == result[i].Time && (x.LogicalName.SequenceEqual(Flags.DeviceTotal) || x.LogicalName.SequenceEqual(Flags.DeviceTotal7))).Select(x => x.NormValue).FirstOrDefault() / 1000;
}
Answer the question
In order to leave comments, you need to log in
changed IEnumerable to IList, everything started working instantly
If possible
write Select at the beginning, this will reduce the number of columns you are pulling.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question