forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssociationKey.cs
44 lines (39 loc) · 1.01 KB
/
AssociationKey.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
namespace NHibernate.Engine
{
/// <summary>
/// Identifies a named association belonging to a particular
/// entity instance. Used to record the fact that an association
/// is null during loading.
/// </summary>
[Serializable]
internal sealed class AssociationKey
{
private readonly EntityKey ownerKey;
private readonly string propertyName;
public AssociationKey(EntityKey ownerKey, string propertyName)
{
this.ownerKey = ownerKey;
this.propertyName = propertyName;
}
public override bool Equals(object that)
{
// NH : Different behavior for NH-1584
if (this == that)
{
return true;
}
var key = that as AssociationKey;
if (key == null)
{
return false;
}
return key.propertyName.Equals(propertyName) && key.ownerKey.Equals(ownerKey)
&& key.ownerKey.EntityName.Equals(ownerKey.EntityName);
}
public override int GetHashCode()
{
return ownerKey.GetHashCode() ^ propertyName.GetHashCode() ^ ownerKey.EntityName.GetHashCode();
}
}
}