Skip to content

Commit 003cfbb

Browse files
committed
Merge pull request #350 from nhibernate/NH-3035
NH-3035 - Alias in HQL Order By Clause is Not Replaced
2 parents 5bec76c + f711a84 commit 003cfbb

20 files changed

+4359
-3196
lines changed

src/NHibernate.Test/Hql/Ast/Address.cs

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,104 @@ public class Address
88
private string country;
99
private StateProvince stateProvince;
1010

11-
public string Street
11+
public virtual string Street
1212
{
1313
get { return street; }
1414
set { street = value; }
1515
}
1616

17-
public string City
17+
public virtual string City
1818
{
1919
get { return city; }
2020
set { city = value; }
2121
}
2222

23-
public string PostalCode
23+
public virtual string PostalCode
2424
{
2525
get { return postalCode; }
2626
set { postalCode = value; }
2727
}
2828

29-
public string Country
29+
public virtual string Country
3030
{
3131
get { return country; }
3232
set { country = value; }
3333
}
3434

35-
public StateProvince StateProvince
35+
public virtual StateProvince StateProvince
3636
{
3737
get { return stateProvince; }
3838
set { stateProvince = value; }
3939
}
40+
41+
public override bool Equals(object obj)
42+
{
43+
if (!(obj is Address))
44+
return false;
45+
46+
var otherAddress = ((Address)obj);
47+
48+
if (Street == null ^ otherAddress.Street == null)
49+
{
50+
return false;
51+
}
52+
53+
if (Street != null && otherAddress.Street != null && otherAddress.Street != Street)
54+
{
55+
return false;
56+
}
57+
58+
if (City == null ^ otherAddress.City == null)
59+
{
60+
return false;
61+
}
62+
63+
if (City != null && otherAddress.City != null && otherAddress.City != City)
64+
{
65+
return false;
66+
}
67+
68+
if (PostalCode == null ^ otherAddress.PostalCode == null)
69+
{
70+
return false;
71+
}
72+
73+
if (PostalCode != null && otherAddress.PostalCode != null && otherAddress.PostalCode != PostalCode)
74+
{
75+
return false;
76+
}
77+
78+
if (Country == null ^ otherAddress.Country == null)
79+
{
80+
return false;
81+
}
82+
83+
if (Country != null && otherAddress.Country != null && otherAddress.Country != Country)
84+
{
85+
return false;
86+
}
87+
88+
if (StateProvince == null ^ otherAddress.StateProvince == null)
89+
{
90+
return false;
91+
}
92+
93+
if (StateProvince != null && otherAddress.StateProvince != null && !otherAddress.StateProvince.Equals(StateProvince))
94+
{
95+
return false;
96+
}
97+
98+
return true;
99+
}
100+
101+
public override int GetHashCode()
102+
{
103+
int result = street != null ? street.GetHashCode() : 0;
104+
result = 31 * result + (city != null ? city.GetHashCode() : 0);
105+
result = 31 * result + (postalCode != null ? postalCode.GetHashCode() : 0);
106+
result = 31 * result + (country != null ? country.GetHashCode() : 0);
107+
result = 31 * result + (stateProvince != null ? stateProvince.GetHashCode() : 0);
108+
return result;
109+
}
40110
}
41111
}

0 commit comments

Comments
 (0)