This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
tests/ServiceStack.OrmLite.Tests/Issues Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,48 @@ public void Can_compare_null_constant_in_subquery_nested_in_SqlExpression()
61
61
results . PrintDump ( ) ;
62
62
}
63
63
}
64
+
65
+ public class Person2
66
+ {
67
+ [ AutoIncrement ]
68
+ public int Id { get ; set ; }
69
+
70
+ public string Name { get ; set ; }
71
+ }
72
+
73
+ public class Order2
74
+ {
75
+ [ AutoIncrement ]
76
+ public int Id { get ; set ; }
77
+
78
+ [ References ( typeof ( Person2 ) ) ]
79
+ public int Person2Id { get ; set ; }
80
+
81
+ public DateTime OrderDate { get ; set ; }
82
+
83
+ public int OrderTypeId { get ; set ; }
84
+ }
85
+
86
+ [ Test ]
87
+ public void Can_reference_variable_in_sub_expression ( )
88
+ {
89
+ int orderTypeId = 2 ;
90
+
91
+ using ( var db = OpenDbConnection ( ) )
92
+ {
93
+ var subExpr = db . From < Order2 > ( )
94
+ . Where ( y => y . OrderTypeId == orderTypeId )
95
+ . Select ( y => y . Person2Id ) ;
96
+
97
+ subExpr . ToSelectStatement ( ) . Print ( ) ;
98
+ Assert . That ( subExpr . ToSelectStatement ( ) . NormalizeSql ( ) , Is . StringContaining ( "@0" ) ) ;
99
+
100
+ var expr = db . From < Person2 > ( )
101
+ . Where ( x => Sql . In ( x . Id , subExpr ) ) ;
102
+
103
+ expr . ToSelectStatement ( ) . Print ( ) ;
104
+ Assert . That ( expr . ToSelectStatement ( ) . NormalizeSql ( ) , Is . StringContaining ( "@0" ) ) ;
105
+ }
106
+ }
64
107
}
65
108
}
You can’t perform that action at this time.
0 commit comments