Remove lazy loading

This commit is contained in:
Pat Hartl 2024-11-27 01:51:47 -06:00
parent 6c75c260f4
commit 5f00f2100a
32 changed files with 91 additions and 97 deletions

View file

@ -22,7 +22,6 @@ namespace LANCommander.Launcher.Data
optionsBuilder.UseLoggerFactory(LoggerFactory);
optionsBuilder.UseSqlite($"Data Source={dbPath};Cache=Shared");
optionsBuilder.UseLazyLoadingProxies();
}
protected override void OnModelCreating(ModelBuilder builder)

View file

@ -16,7 +16,6 @@
<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>

View file

@ -11,7 +11,6 @@
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />

View file

@ -17,12 +17,12 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Actions")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public Guid? ServerId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(ServerId))]
[InverseProperty("Actions")]
public virtual Server? Server { get; set; }
public Server? Server { get; set; }
}
}

View file

@ -17,22 +17,22 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(StorageLocationId))]
[InverseProperty(nameof(StorageLocation.Archives))]
public virtual StorageLocation StorageLocation { get; set; }
public StorageLocation StorageLocation { get; set; }
public Guid? GameId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Archives")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public Guid? RedistributableId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(RedistributableId))]
[InverseProperty("Archives")]
public virtual Redistributable? Redistributable { get; set; }
public Redistributable? Redistributable { get; set; }
[Display(Name = "Last Version")]
public virtual Archive? LastVersion { get; set; }
public Archive? LastVersion { get; set; }
[Display(Name = "Uncompressed Size")]
public long UncompressedSize { get; set; }

View file

@ -16,7 +16,7 @@ namespace LANCommander.Server.Data.Models
[ForeignKey(nameof(CreatedById))]
[Display(Name = "Created By")]
public virtual User? CreatedBy { get; set; }
public User? CreatedBy { get; set; }
[Display(Name = "Updated On")]
public DateTime UpdatedOn { get; set; }
@ -25,6 +25,6 @@ namespace LANCommander.Server.Data.Models
[ForeignKey(nameof(UpdatedById))]
[Display(Name = "Updated By")]
public virtual User? UpdatedBy { get; set; }
public User? UpdatedBy { get; set; }
}
}

View file

@ -6,6 +6,6 @@ namespace LANCommander.Server.Data.Models
{
public string Name { get; set; }
[JsonIgnore]
public virtual ICollection<Game> Games { get; set; }
public ICollection<Game> Games { get; set; }
}
}

View file

@ -5,7 +5,7 @@ namespace LANCommander.Server.Data.Models
[Table("Categories")]
public class Category : BaseTaxonomyModel
{
public virtual Category Parent { get; set; }
public virtual ICollection<Category> Children { get; set; }
public Category Parent { get; set; }
public ICollection<Category> Children { get; set; }
}
}

View file

@ -7,6 +7,6 @@ namespace LANCommander.Server.Data.Models
public class Collection : BaseTaxonomyModel
{
[JsonIgnore]
public virtual ICollection<Role> Roles { get; set; }
public ICollection<Role> Roles { get; set; }
}
}

View file

@ -7,8 +7,8 @@ namespace LANCommander.Server.Data.Models
public string Name { get; set; }
[JsonIgnore]
public virtual ICollection<Game> PublishedGames { get; set; }
public ICollection<Game> PublishedGames { get; set; }
[JsonIgnore]
public virtual ICollection<Game> DevelopedGames { get; set; }
public ICollection<Game> DevelopedGames { get; set; }
}
}

View file

@ -34,28 +34,28 @@ namespace LANCommander.Server.Data.Models
[ForeignKey(nameof(EngineId))]
public virtual Engine Engine { get; set; }
public virtual ICollection<MultiplayerMode>? MultiplayerModes { get; set; } = new List<MultiplayerMode>();
public virtual ICollection<Genre>? Genres { get; set; } = new List<Genre>();
public virtual ICollection<Tag>? Tags { get; set; } = new List<Tag>();
public virtual ICollection<Platform>? Platforms { get; set; } = new List<Platform>();
public virtual ICollection<Category>? Categories { get; set; } = new List<Category>();
public virtual ICollection<Company>? Publishers { get; set; } = new List<Company>();
public virtual ICollection<Company>? Developers { get; set; } = new List<Company>();
public virtual ICollection<Archive>? Archives { get; set; } = new List<Archive>();
public virtual ICollection<Script>? Scripts { get; set; } = new List<Script>();
public virtual ICollection<GameSave>? GameSaves { get; set; } = new List<GameSave>();
public virtual ICollection<PlaySession>? PlaySessions { get; set; } = new List<PlaySession>();
public virtual ICollection<SavePath>? SavePaths { get; set; } = new List<SavePath>();
public virtual ICollection<Server>? Servers { get; set; } = new List<Server>();
public virtual ICollection<Redistributable>? Redistributables { get; set; } = new List<Redistributable>();
public virtual ICollection<Media>? Media { get; set; } = new List<Media>();
public ICollection<MultiplayerMode>? MultiplayerModes { get; set; } = new List<MultiplayerMode>();
public ICollection<Genre>? Genres { get; set; } = new List<Genre>();
public ICollection<Tag>? Tags { get; set; } = new List<Tag>();
public ICollection<Platform>? Platforms { get; set; } = new List<Platform>();
public ICollection<Category>? Categories { get; set; } = new List<Category>();
public ICollection<Company>? Publishers { get; set; } = new List<Company>();
public ICollection<Company>? Developers { get; set; } = new List<Company>();
public ICollection<Archive>? Archives { get; set; } = new List<Archive>();
public ICollection<Script>? Scripts { get; set; } = new List<Script>();
public ICollection<GameSave>? GameSaves { get; set; } = new List<GameSave>();
public ICollection<PlaySession>? PlaySessions { get; set; } = new List<PlaySession>();
public ICollection<SavePath>? SavePaths { get; set; } = new List<SavePath>();
public ICollection<Server>? Servers { get; set; } = new List<Server>();
public ICollection<Redistributable>? Redistributables { get; set; } = new List<Redistributable>();
public ICollection<Media>? Media { get; set; } = new List<Media>();
public string? ValidKeyRegex { get; set; }
public virtual ICollection<Key>? Keys { get; set; } = new List<Key>();
public virtual ICollection<Collection> Collections { get; set; } = new List<Collection>();
public virtual ICollection<Game> DependentGames { get; set; } = new List<Game>();
public virtual ICollection<Issue> Issues { get; set; } = new List<Issue>();
public virtual ICollection<Page>? Pages { get; set; }
public virtual ICollection<Library> Libraries { get; set; } = new List<Library>();
public ICollection<Key>? Keys { get; set; } = new List<Key>();
public ICollection<Collection> Collections { get; set; } = new List<Collection>();
public ICollection<Game> DependentGames { get; set; } = new List<Game>();
public ICollection<Issue> Issues { get; set; } = new List<Issue>();
public ICollection<Page>? Pages { get; set; }
public ICollection<Library> Libraries { get; set; } = new List<Library>();
}
}

View file

@ -10,7 +10,7 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(StorageLocationId))]
[InverseProperty(nameof(StorageLocation.GameSaves))]
public virtual StorageLocation StorageLocation { get; set; }
public StorageLocation StorageLocation { get; set; }
public long Size { get; set; }
@ -18,11 +18,11 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("GameSaves")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public Guid UserId { get; set; }
[ForeignKey(nameof(UserId))]
[InverseProperty("GameSaves")]
public virtual User? User { get; set; }
public User? User { get; set; }
}
}

View file

@ -14,9 +14,9 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Issues")]
public virtual Game Game { get; set; }
public Game Game { get; set; }
[Display(Name = "Resolved By")]
public virtual User? ResolvedBy { get; set; }
public User? ResolvedBy { get; set; }
}
}

View file

@ -14,7 +14,7 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Keys")]
public virtual Game Game { get; set; }
public Game Game { get; set; }
public KeyAllocationMethod AllocationMethod { get; set; }
[MaxLength(17)]
public string? ClaimedByMacAddress { get; set; }
@ -22,7 +22,7 @@ namespace LANCommander.Server.Data.Models
public string? ClaimedByIpv4Address { get; set; }
[MaxLength(255)]
public string? ClaimedByComputerName { get; set; }
public virtual User? ClaimedByUser { get; set; }
public User? ClaimedByUser { get; set; }
public DateTime? ClaimedOn { get; set; }
public bool IsAllocated()

View file

@ -13,7 +13,7 @@ namespace LANCommander.Server.Data.Models
{
public Guid UserId { get; set; }
[ForeignKey(nameof(UserId))]
public virtual User User { get; set; }
public virtual ICollection<Game> Games { get; set; }
public User User { get; set; }
public ICollection<Game> Games { get; set; }
}
}

View file

@ -22,27 +22,27 @@ namespace LANCommander.Server.Data.Models
[MaxLength(8)]
public string Crc32 { get; set; }
public virtual Media? Thumbnail { get; set; }
public Media? Thumbnail { get; set; }
[JsonIgnore]
public virtual Media? Parent { get; set; }
public Media? Parent { get; set; }
public Guid StorageLocationId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(StorageLocationId))]
[InverseProperty(nameof(StorageLocation.Media))]
public virtual StorageLocation StorageLocation { get; set; }
public StorageLocation StorageLocation { get; set; }
public Guid? GameId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Media")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public Guid? UserId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(UserId))]
[InverseProperty("Media")]
public virtual User? User { get; set; }
public User? User { get; set; }
}
}

View file

@ -17,6 +17,6 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("MultiplayerModes")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
}
}

View file

@ -20,12 +20,12 @@ namespace LANCommander.Server.Data.Models
public Guid? ParentId { get; set; }
[ForeignKey(nameof(ParentId))]
public virtual Page? Parent { get; set; }
public Page? Parent { get; set; }
public virtual ICollection<Page> Children { get; set; }
public ICollection<Page> Children { get; set; }
public virtual ICollection<Game> Games { get; set; }
public virtual ICollection<Redistributable> Redistributables { get; set; }
public virtual ICollection<Server> Servers { get; set; }
public ICollection<Game> Games { get; set; }
public ICollection<Redistributable> Redistributables { get; set; }
public ICollection<Server> Servers { get; set; }
}
}

View file

@ -11,12 +11,12 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("PlaySessions")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public Guid UserId { get; set; }
[ForeignKey(nameof(UserId))]
[InverseProperty("PlaySessions")]
public virtual User? User { get; set; }
public User? User { get; set; }
[Display(Name = "Start")]
public DateTime? Start { get; set; }
@ -24,7 +24,7 @@ namespace LANCommander.Server.Data.Models
[Display(Name = "End")]
public DateTime? End { get; set; }
public virtual TimeSpan? Duration
public TimeSpan? Duration
{
get
{

View file

@ -9,9 +9,9 @@ namespace LANCommander.Server.Data.Models
public string? Description { get; set; }
public string? Notes { get; set; }
public virtual ICollection<Archive>? Archives { get; set; }
public virtual ICollection<Script>? Scripts { get; set; }
public virtual ICollection<Game>? Games { get; set; }
public virtual ICollection<Page>? Pages { get; set; }
public ICollection<Archive>? Archives { get; set; }
public ICollection<Script>? Scripts { get; set; }
public ICollection<Game>? Games { get; set; }
public ICollection<Page>? Pages { get; set; }
}
}

View file

@ -7,9 +7,9 @@ namespace LANCommander.Server.Data.Models
[Table("Roles")]
public class Role : IdentityRole<Guid>, IBaseModel
{
public virtual ICollection<Collection> Collections { get; set; }
public ICollection<Collection> Collections { get; set; }
[NotMapped]
public virtual ICollection<User> Users { get; set; }
public ICollection<User> Users { get; set; }
[Display(Name = "Created On")]
public DateTime CreatedOn { get; set; }
@ -18,7 +18,7 @@ namespace LANCommander.Server.Data.Models
[ForeignKey(nameof(CreatedById))]
[Display(Name = "Created By")]
public virtual User? CreatedBy { get; set; }
public User? CreatedBy { get; set; }
[Display(Name = "Updated On")]
public DateTime UpdatedOn { get; set; }
@ -27,6 +27,6 @@ namespace LANCommander.Server.Data.Models
[ForeignKey(nameof(UpdatedById))]
[Display(Name = "Updated By")]
public virtual User? UpdatedBy { get; set; }
public User? UpdatedBy { get; set; }
}
}

View file

@ -16,6 +16,6 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("SavePaths")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
}
}

View file

@ -19,18 +19,18 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Scripts")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public Guid? RedistributableId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(RedistributableId))]
[InverseProperty("Scripts")]
public virtual Redistributable? Redistributable { get; set; }
public Redistributable? Redistributable { get; set; }
public Guid? ServerId { get; set; }
[JsonIgnore]
[ForeignKey(nameof(ServerId))]
[InverseProperty("Scripts")]
public virtual Server? Server { get; set; }
public Server? Server { get; set; }
}
}

View file

@ -27,12 +27,12 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(GameId))]
[InverseProperty("Servers")]
public virtual Game? Game { get; set; }
public Game? Game { get; set; }
public virtual ICollection<ServerConsole>? ServerConsoles { get; set; }
public virtual ICollection<ServerHttpPath>? HttpPaths { get; set; }
public virtual ICollection<Script>? Scripts { get; set; }
public virtual ICollection<Action>? Actions { get; set; } = new List<Action>();
public virtual ICollection<Page>? Pages { get; set; }
public ICollection<ServerConsole>? ServerConsoles { get; set; }
public ICollection<ServerHttpPath>? HttpPaths { get; set; }
public ICollection<Script>? Scripts { get; set; }
public ICollection<Action>? Actions { get; set; } = new List<Action>();
public ICollection<Page>? Pages { get; set; }
}
}

View file

@ -21,6 +21,6 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(ServerId))]
[InverseProperty("ServerConsoles")]
public virtual Server? Server { get; set; }
public Server? Server { get; set; }
}
}

View file

@ -12,6 +12,6 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(ServerId))]
[InverseProperty("HttpPaths")]
public virtual Server Server { get; set; }
public Server Server { get; set; }
}
}

View file

@ -14,8 +14,8 @@ namespace LANCommander.Server.Data.Models
public bool Default { get; set; }
public string Path { get; set; }
public StorageLocationType Type { get; set; }
public virtual ICollection<Archive>? Archives { get; set; } = new List<Archive>();
public virtual ICollection<GameSave>? GameSaves { get; set; } = new List<GameSave>();
public virtual ICollection<Media>? Media { get; set; } = new List<Media>();
public ICollection<Archive>? Archives { get; set; } = new List<Archive>();
public ICollection<GameSave>? GameSaves { get; set; } = new List<GameSave>();
public ICollection<Media>? Media { get; set; } = new List<Media>();
}
}

View file

@ -43,17 +43,17 @@ namespace LANCommander.Server.Data.Models
public DateTime RefreshTokenExpiration { get; set; }
[JsonIgnore]
public virtual ICollection<GameSave>? GameSaves { get; set; }
public ICollection<GameSave>? GameSaves { get; set; }
[JsonIgnore]
public virtual ICollection<PlaySession>? PlaySessions { get; set; }
public ICollection<PlaySession>? PlaySessions { get; set; }
[JsonIgnore]
public virtual ICollection<Media>? Media { get; set; }
public ICollection<Media>? Media { get; set; }
[NotMapped]
public virtual ICollection<Role>? Roles { get; set; }
public virtual ICollection<UserCustomField>? CustomFields { get; set; }
public ICollection<Role>? Roles { get; set; }
public ICollection<UserCustomField>? CustomFields { get; set; }
[JsonIgnore]
public bool Approved { get; set; }
@ -73,7 +73,7 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[Display(Name = "Created By")]
public virtual User? CreatedBy { get; set; }
public User? CreatedBy { get; set; }
[JsonIgnore]
[Display(Name = "Updated On")]
@ -85,8 +85,8 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[Display(Name = "Updated By")]
public virtual User? UpdatedBy { get; set; }
public User? UpdatedBy { get; set; }
public virtual Library Library { get; set; }
public Library Library { get; set; }
}
}

View file

@ -16,6 +16,6 @@ namespace LANCommander.Server.Data.Models
[JsonIgnore]
[ForeignKey(nameof(UserId))]
[InverseProperty("CustomFields")]
public virtual User? User { get; set; }
public User? User { get; set; }
}
}

View file

@ -1,5 +1,4 @@
using AutoMapper;
using Castle.Core.Logging;
using LANCommander.Server.Data.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;

View file

@ -1,5 +1,4 @@
using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Linq.Expressions;
using System.Reflection;

View file

@ -90,7 +90,6 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>