Skip to content

Commit 7f1fdc1

Browse files
committed
Test case for component
1 parent b6fd5b3 commit 7f1fdc1

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/NHibernate.Test/NHSpecificTest/GH3218/ContainsParameterFixture.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ protected override HbmMapping GetMappings()
1616
{
1717
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
1818
rc.Property(x => x.Name);
19+
rc.Component(
20+
x => x.Component,
21+
ekm =>
22+
{
23+
ekm.Property(ek => ek.Id1);
24+
ekm.Property(ek => ek.Id2);
25+
});
1926
});
2027
mapper.Class<Entity>(rc =>
2128
{
@@ -26,7 +33,7 @@ protected override HbmMapping GetMappings()
2633

2734
return mapper.CompileMappingForAllExplicitlyAddedEntities();
2835
}
29-
36+
3037
[Test]
3138
public void ContainsOnId()
3239
{
@@ -68,5 +75,15 @@ public void ContainsOnName()
6875
session.Query<Entity>().Where(x => x.List.Select(l => l.Name).Contains(client)).ToList();
6976
}
7077
}
78+
79+
[Test]
80+
public void ContainsOnComponent()
81+
{
82+
using (var session = OpenSession())
83+
{
84+
var client = new CompositeKey() { Id1 = 1, Id2 = 2 };
85+
session.Query<Entity>().Where(x => x.List.Select(l => l.Component).Contains(client)).ToList();
86+
}
87+
}
7188
}
7289
}

src/NHibernate.Test/NHSpecificTest/GH3218/Entity.cs

+23
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,28 @@ public class Child
1414
{
1515
public virtual Guid Id { get; set; }
1616
public virtual string Name { get; set; }
17+
public virtual CompositeKey Component { get; set; }
18+
}
19+
20+
public class CompositeKey
21+
{
22+
public int Id1 { get; set; }
23+
public int Id2 { get; set; }
24+
25+
public override bool Equals(object obj)
26+
{
27+
var key = obj as CompositeKey;
28+
return key != null
29+
&& Id1 == key.Id1
30+
&& Id2 == key.Id2;
31+
}
32+
33+
public override int GetHashCode()
34+
{
35+
var hashCode = -1596524975;
36+
hashCode = hashCode * -1521134295 + Id1.GetHashCode();
37+
hashCode = hashCode * -1521134295 + Id2.GetHashCode();
38+
return hashCode;
39+
}
1740
}
1841
}

0 commit comments

Comments
 (0)