From ecae6fb7ba54d138f4381b2b4b1dab93a1ee2f55 Mon Sep 17 00:00:00 2001 From: hydrant Date: Fri, 10 May 2019 21:16:43 +0200 Subject: [PATCH] removed unneccesary groupvehicle method --- ReallifeGamemode.Server/Entities/GroupVehicle.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) 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; } } }