From ce473770016f0bef57bb7e129b5c9b88560882dd Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 8 Feb 2024 00:57:03 +0100 Subject: [PATCH] [backend/database] Make sure all projectable entity properties aren't mapped --- .../Core/Database/Tables/Note.cs | 1 + .../Core/Database/Tables/User.cs | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Iceshrimp.Backend/Core/Database/Tables/Note.cs b/Iceshrimp.Backend/Core/Database/Tables/Note.cs index b3459888..9a170fc8 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Note.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Note.cs @@ -70,6 +70,7 @@ public class Note : IEntity { [Column("visibility")] public NoteVisibility Visibility { get; set; } + [NotMapped] [Projectable] [SuppressMessage("ReSharper", "MergeIntoLogicalPattern", Justification = "Projectable expression cannot contain patterns")] diff --git a/Iceshrimp.Backend/Core/Database/Tables/User.cs b/Iceshrimp.Backend/Core/Database/Tables/User.cs index d4975952..2d905490 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/User.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/User.cs @@ -296,9 +296,9 @@ public class User : IEntity { [InverseProperty(nameof(Tables.Blocking.Blocker))] public virtual ICollection OutgoingBlocks { get; set; } = new List(); - [Projectable] public virtual IEnumerable BlockedBy => IncomingBlocks.Select(p => p.Blocker); + [NotMapped] [Projectable] public virtual IEnumerable BlockedBy => IncomingBlocks.Select(p => p.Blocker); - [Projectable] public virtual IEnumerable Blocking => OutgoingBlocks.Select(p => p.Blockee); + [NotMapped] [Projectable] public virtual IEnumerable Blocking => OutgoingBlocks.Select(p => p.Blockee); [InverseProperty(nameof(ChannelFollowing.Follower))] public virtual ICollection ChannelFollowings { get; set; } = new List(); @@ -320,10 +320,13 @@ public class User : IEntity { [InverseProperty(nameof(FollowRequest.Follower))] public virtual ICollection OutgoingFollowRequests { get; set; } = new List(); + [NotMapped] [Projectable] public virtual IEnumerable ReceivedFollowRequests => IncomingFollowRequests.Select(p => p.Follower); - [Projectable] public virtual IEnumerable SentFollowRequests => OutgoingFollowRequests.Select(p => p.Followee); + [NotMapped] + [Projectable] + public virtual IEnumerable SentFollowRequests => OutgoingFollowRequests.Select(p => p.Followee); [InverseProperty(nameof(Tables.Following.Followee))] public virtual ICollection IncomingFollowRelationships { get; set; } = new List(); @@ -331,9 +334,13 @@ public class User : IEntity { [InverseProperty(nameof(Tables.Following.Follower))] public virtual ICollection OutgoingFollowRelationships { get; set; } = new List(); - [Projectable] public virtual IEnumerable Followers => IncomingFollowRelationships.Select(p => p.Follower); + [NotMapped] + [Projectable] + public virtual IEnumerable Followers => IncomingFollowRelationships.Select(p => p.Follower); - [Projectable] public virtual IEnumerable Following => OutgoingFollowRelationships.Select(p => p.Followee); + [NotMapped] + [Projectable] + public virtual IEnumerable Following => OutgoingFollowRelationships.Select(p => p.Followee); [InverseProperty(nameof(GalleryLike.User))] public virtual ICollection GalleryLikes { get; set; } = new List(); @@ -360,9 +367,9 @@ public class User : IEntity { [InverseProperty(nameof(Tables.Muting.Muter))] public virtual ICollection OutgoingMutes { get; set; } = new List(); - [Projectable] public virtual IEnumerable MutedBy => IncomingMutes.Select(p => p.Muter); + [NotMapped] [Projectable] public virtual IEnumerable MutedBy => IncomingMutes.Select(p => p.Muter); - [Projectable] public virtual IEnumerable Muting => OutgoingMutes.Select(p => p.Mutee); + [NotMapped] [Projectable] public virtual IEnumerable Muting => OutgoingMutes.Select(p => p.Mutee); [InverseProperty(nameof(NoteFavorite.User))] public virtual ICollection NoteFavorites { get; set; } = new List(); @@ -445,7 +452,7 @@ public class User : IEntity { [InverseProperty(nameof(UserNotePin.User))] public virtual ICollection UserNotePins { get; set; } = new List(); - [Projectable] public virtual IEnumerable PinnedNotes => UserNotePins.Select(p => p.Note); + [NotMapped] [Projectable] public virtual IEnumerable PinnedNotes => UserNotePins.Select(p => p.Note); [InverseProperty(nameof(Tables.UserProfile.User))] public virtual UserProfile? UserProfile { get; set; }