Compare commits
2 Commits
d38f26291f
...
e8aa6423ed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8aa6423ed | ||
|
|
b5755642aa |
@ -7,6 +7,5 @@ public class ActorType
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
// Navigation Property
|
|
||||||
public List<Actor> Actors { get; set; } = new List<Actor>();
|
public List<Actor> Actors { get; set; } = new List<Actor>();
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace Iot.Entities;
|
namespace Iot.Entities;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@ -10,7 +10,6 @@ public class Measurement
|
|||||||
public int MeasurementTypeId { get; set; }
|
public int MeasurementTypeId { get; set; }
|
||||||
public double Value { get; set; }
|
public double Value { get; set; }
|
||||||
|
|
||||||
// Navigation Properties
|
|
||||||
public Actor Actor { get; set; }
|
public Actor Actor { get; set; }
|
||||||
public MeasurementType MeasurementType { get; set; }
|
public MeasurementType MeasurementType { get; set; }
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace Iot.Entities;
|
namespace Iot.Entities;
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@ -8,6 +8,5 @@ public class MeasurementType
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Comment { get; set; }
|
public string Comment { get; set; }
|
||||||
|
|
||||||
// Navigation Property
|
|
||||||
public List<Measurement> Measurements { get; set; } = new List<Measurement>();
|
public List<Measurement> Measurements { get; set; } = new List<Measurement>();
|
||||||
}
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------
|
/*--------------------------------------------------------------
|
||||||
* HTBLA-Leonding / Class: 1xHIF
|
* HTBLA-Leonding / Class: 4CHIF
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
* Musterlösung-HA
|
* Musterlösung-Hinterdorfer Jonas
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
* Description: Iot
|
* Description: Iot
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
@ -98,22 +98,18 @@ var measurements = measurementsCsv.Select(m =>
|
|||||||
};
|
};
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
|
||||||
// Populate Actor.Measurements using ToLookup (O(n) instead of O(n*m))
|
|
||||||
var measurementsByActor = measurements.ToLookup(m => m.ActorId);
|
var measurementsByActor = measurements.ToLookup(m => m.ActorId);
|
||||||
foreach (var actor in actors)
|
foreach (var actor in actors)
|
||||||
{
|
{
|
||||||
actor.Measurements = measurementsByActor[actor.Id].ToList();
|
actor.Measurements = measurementsByActor[actor.Id].ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate MeasurementType.Measurements using ToLookup (O(n) instead of O(n*m))
|
|
||||||
var measurementsByType = measurements.ToLookup(m => m.MeasurementTypeId);
|
var measurementsByType = measurements.ToLookup(m => m.MeasurementTypeId);
|
||||||
foreach (var measurementType in measurementTypes)
|
foreach (var measurementType in measurementTypes)
|
||||||
{
|
{
|
||||||
measurementType.Measurements = measurementsByType[measurementType.Id].ToList();
|
measurementType.Measurements = measurementsByType[measurementType.Id].ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate ActorType.Actors using ToLookup (O(n) instead of O(n*m))
|
|
||||||
var actorsByType = actors.ToLookup(a => a.ActorTypeId);
|
var actorsByType = actors.ToLookup(a => a.ActorTypeId);
|
||||||
foreach (var actorType in actorTypes.Values)
|
foreach (var actorType in actorTypes.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user