Skip to content

Commit

Permalink
Don't override Equals or GetHashCode.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTedder committed Sep 6, 2024
1 parent 3918f3a commit c3d8aad
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 41 deletions.
17 changes: 0 additions & 17 deletions LeaderboardBackend/Models/Entities/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,4 @@ public class Category : IHasCreationTimestamp
/// The time at which the Category was deleted, or <see langword="null" /> if the Category has not been deleted.
/// </summary>
public Instant? DeletedAt { get; set; }

public override bool Equals(object? obj)
{
return obj is Category category
&& Id == category.Id
&& Name == category.Name
&& Slug == category.Slug
&& Info == category.Info
&& SortDirection == category.SortDirection
&& Type == category.Type
&& LeaderboardId == category.LeaderboardId;
}

public override int GetHashCode()
{
return HashCode.Combine(Id, Name, Slug, LeaderboardId, Info, SortDirection, Type);
}
}
14 changes: 0 additions & 14 deletions LeaderboardBackend/Models/Entities/Leaderboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,6 @@ public class Leaderboard : IHasCreationTimestamp
/// A collection of `Category` entities for the `Leaderboard`.
/// </summary>
public List<Category>? Categories { get; set; }

public override bool Equals(object? obj)
{
return obj is Leaderboard leaderboard
&& Id == leaderboard.Id
&& Name == leaderboard.Name
&& Slug == leaderboard.Slug
&& Info == leaderboard.Info;
}

public override int GetHashCode()
{
return HashCode.Combine(Id, Name, Slug, Info);
}
}

public class LeaderboardEntityTypeConfig : IEntityTypeConfiguration<Leaderboard>
Expand Down
10 changes: 0 additions & 10 deletions LeaderboardBackend/Models/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ public class User : IHasCreationTimestamp
public Instant CreatedAt { get; set; }

public bool IsAdmin => Role == UserRole.Administrator;

public override bool Equals(object? obj)
{
return obj is User user && Id.Equals(user.Id);
}

public override int GetHashCode()
{
return HashCode.Combine(Id, Username, Email);
}
}

public class UserEntityTypeConfig : IEntityTypeConfiguration<User>
Expand Down

0 comments on commit c3d8aad

Please sign in to comment.