diff --git a/ReallifeGamemode.Server/Entities/GroupVehicle.cs b/ReallifeGamemode.Server/Entities/GroupVehicle.cs index 2e707901..e89b849b 100644 --- a/ReallifeGamemode.Server/Entities/GroupVehicle.cs +++ b/ReallifeGamemode.Server/Entities/GroupVehicle.cs @@ -1,4 +1,5 @@ -using ReallifeGamemode.Server.Models; +using Microsoft.EntityFrameworkCore; +using ReallifeGamemode.Server.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; @@ -14,17 +15,10 @@ namespace ReallifeGamemode.Server.Entities [ForeignKey("Group")] public int? GroupId { get; set; } - public Group GetGroup() - { - using (var dbContext = new DatabaseContext()) - { - return dbContext.Groups.Where(g => g.Id == GroupId).FirstOrDefault(); - } - } - public override string ToString() { - return "Gruppen Fahrzeug | Gruppe: " + Group.Name; + using(var dbContext = new DatabaseContext()) + return "Gruppen Fahrzeug | Gruppe: " + dbContext.GroupVehicles.Include(g => g.Group).First(g => g.Id == this.Id).Group.Name; } } }