refactor: remove commented navigation properties and clean up namespaces

This commit is contained in:
Jonas Hinterdorfer 2026-01-15 15:03:48 +01:00
parent b5755642aa
commit e8aa6423ed
5 changed files with 5 additions and 14 deletions

View File

@ -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>();
} }

View File

@ -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; }
} }

View File

@ -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>();
} }

View File

@ -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)
{ {

View File

@ -16,8 +16,6 @@
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = [ packages = [
pkgs.dotnet-sdk_9 pkgs.dotnet-sdk_9
# alternativ/zusätzlich:
# pkgs.dotnetCorePackages.sdk_9_0
]; ];
}; };
}); });