File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
Async/NHSpecificTest/NH3426 Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -84,5 +84,18 @@ public async Task WhereGuidToStringAsync()
84
84
Assert . That ( list , Has . Count . EqualTo ( 1 ) ) ;
85
85
}
86
86
}
87
+
88
+ [ Test ]
89
+ public async Task CompareStringColumnWithGuidToStringAsync ( )
90
+ {
91
+ using ( var session = OpenSession ( ) )
92
+ {
93
+ var list = await ( session . Query < Entity > ( )
94
+ . Where ( x => x . Id . ToString ( ) == x . Name )
95
+ . ToListAsync ( ) ) ;
96
+
97
+ Assert . That ( list , Has . Count . EqualTo ( 0 ) ) ;
98
+ }
99
+ }
87
100
}
88
101
}
Original file line number Diff line number Diff line change @@ -72,5 +72,18 @@ public void WhereGuidToString()
72
72
Assert . That ( list , Has . Count . EqualTo ( 1 ) ) ;
73
73
}
74
74
}
75
+
76
+ [ Test ]
77
+ public void CompareStringColumnWithGuidToString ( )
78
+ {
79
+ using ( var session = OpenSession ( ) )
80
+ {
81
+ var list = session . Query < Entity > ( )
82
+ . Where ( x => x . Id . ToString ( ) == x . Name )
83
+ . ToList ( ) ;
84
+
85
+ Assert . That ( list , Has . Count . EqualTo ( 0 ) ) ;
86
+ }
87
+ }
75
88
}
76
89
}
Original file line number Diff line number Diff line change @@ -352,6 +352,7 @@ protected virtual void RegisterFunctions()
352
352
// Casting to CHAR (without specified length) truncates to 30 characters.
353
353
// A longer version would be safer, but 50 is enough to prevent errors when casting uniqueidentifer to a string representation (NH-2858)
354
354
RegisterFunction ( "str" , new SQLFunctionTemplate ( NHibernateUtil . String , "cast(?1 as nvarchar(50))" ) ) ;
355
+ RegisterFunction ( "strguid" , new SQLFunctionTemplate ( NHibernateUtil . String , "cast(?1 as char(36))" ) ) ;
355
356
356
357
RegisterFunction ( "substring" , new EmulatedLengthSubstringFunction ( ) ) ;
357
358
You can’t perform that action at this time.
0 commit comments