using System.Diagnostics.CodeAnalysis; using SQLite; namespace Innovenergy.Backend.Model.Relations; public abstract class Relation { [PrimaryKey, AutoIncrement] [Obsolete("Do not use for any business logic")] public Int64 Id { get; set; } [Ignore] protected L Left { get; set; } = default!; [Ignore] protected R Right { get; set; } = default!; protected Boolean Equals(Relation other) { return EqualityComparer.Default.Equals(Left, other.Left) && EqualityComparer.Default.Equals(Right, other.Right); } public override Boolean Equals(Object? obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.GetType() == GetType() && Equals((Relation)obj); } [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")] public override Int32 GetHashCode() => HashCode.Combine(Left, Right); public static Boolean operator ==(Relation? left, Relation? right) => Equals(left, right); public static Boolean operator !=(Relation? left, Relation? right) => !Equals(left, right); }