File tree 2 files changed +41
-1
lines changed
src/NHibernate.Test/NHSpecificTest/GH3218
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ protected override HbmMapping GetMappings()
16
16
{
17
17
rc . Id ( x => x . Id , m => m . Generator ( Generators . GuidComb ) ) ;
18
18
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
+ } ) ;
19
26
} ) ;
20
27
mapper . Class < Entity > ( rc =>
21
28
{
@@ -26,7 +33,7 @@ protected override HbmMapping GetMappings()
26
33
27
34
return mapper . CompileMappingForAllExplicitlyAddedEntities ( ) ;
28
35
}
29
-
36
+
30
37
[ Test ]
31
38
public void ContainsOnId ( )
32
39
{
@@ -68,5 +75,15 @@ public void ContainsOnName()
68
75
session . Query < Entity > ( ) . Where ( x => x . List . Select ( l => l . Name ) . Contains ( client ) ) . ToList ( ) ;
69
76
}
70
77
}
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
+ }
71
88
}
72
89
}
Original file line number Diff line number Diff line change @@ -14,5 +14,28 @@ public class Child
14
14
{
15
15
public virtual Guid Id { get ; set ; }
16
16
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
+ }
17
40
}
18
41
}
You can’t perform that action at this time.
0 commit comments