Avoid circular references with some models

This commit is contained in:
Pat Hartl 2023-01-12 01:25:32 -06:00
parent 21328163f7
commit e5b5b1f895
6 changed files with 15 additions and 1 deletions

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models namespace LANCommander.Data.Models
{ {
@ -11,6 +12,7 @@ namespace LANCommander.Data.Models
public string WorkingDirectory { get; set; } public string WorkingDirectory { get; set; }
public bool PrimaryAction { get; set; } public bool PrimaryAction { get; set; }
[JsonIgnore]
public virtual Game Game { get; set; } public virtual Game Game { get; set; }
} }
} }

View file

@ -1,10 +1,14 @@
namespace LANCommander.Data.Models using System.Text.Json.Serialization;
namespace LANCommander.Data.Models
{ {
public class Company : BaseModel public class Company : BaseModel
{ {
public string Name { get; set; } public string Name { get; set; }
[JsonIgnore]
public virtual ICollection<Game> PublishedGames { get; set; } public virtual ICollection<Game> PublishedGames { get; set; }
[JsonIgnore]
public virtual ICollection<Game> DevelopedGames { get; set; } public virtual ICollection<Game> DevelopedGames { get; set; }
} }
} }

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models namespace LANCommander.Data.Models
{ {
@ -6,6 +7,7 @@ namespace LANCommander.Data.Models
public class Genre : BaseModel public class Genre : BaseModel
{ {
public string Name { get; set; } public string Name { get; set; }
[JsonIgnore]
public virtual ICollection<Game> Games { get; set; } public virtual ICollection<Game> Games { get; set; }
} }
} }

View file

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models namespace LANCommander.Data.Models
{ {
@ -8,6 +9,7 @@ namespace LANCommander.Data.Models
{ {
[MaxLength(255)] [MaxLength(255)]
public string Value { get; set; } public string Value { get; set; }
[JsonIgnore]
public virtual Game Game { get; set; } public virtual Game Game { get; set; }
public KeyAllocationMethod AllocationMethod { get; set; } public KeyAllocationMethod AllocationMethod { get; set; }
[MaxLength(17)] [MaxLength(17)]

View file

@ -1,5 +1,6 @@
using LANCommander.Data.Enums; using LANCommander.Data.Enums;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models namespace LANCommander.Data.Models
{ {
@ -13,6 +14,7 @@ namespace LANCommander.Data.Models
public int MaxPlayers { get; set; } public int MaxPlayers { get; set; }
public int Spectators { get; set; } public int Spectators { get; set; }
[JsonIgnore]
public virtual Game Game { get; set; } public virtual Game Game { get; set; }
} }
} }

View file

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace LANCommander.Data.Models namespace LANCommander.Data.Models
{ {
@ -8,6 +9,7 @@ namespace LANCommander.Data.Models
{ {
public string Name { get; set; } public string Name { get; set; }
[JsonIgnore]
public virtual List<Game> Games { get; set; } public virtual List<Game> Games { get; set; }
} }
} }