File tree 5 files changed +51
-4
lines changed
NHibernate.DomainModel/Northwind
5 files changed +51
-4
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ public virtual DateTime? OrderDate
47
47
set { _orderDate = value ; }
48
48
}
49
49
50
+ public virtual DateTime RequiredOrderDate { get ; set ; }
51
+
50
52
public virtual DateTime ? RequiredDate
51
53
{
52
54
get { return _requiredDate ; }
@@ -106,4 +108,4 @@ public virtual void RemoveOrderLine(OrderLine orderLine)
106
108
}
107
109
}
108
110
}
109
- }
111
+ }
Original file line number Diff line number Diff line change 17
17
<property name =" OrderDate" column =" OrderDate" type =" DateTime"
18
18
access=" field.camelcase-underscore" />
19
19
20
+
21
+ <property name =" RequiredOrderDate" formula =" OrderDate" insert =" false" update =" false" />
22
+
20
23
<property name =" RequiredDate" column =" RequiredDate" type =" DateTime"
21
24
access=" field.camelcase-underscore" />
22
25
60
63
61
64
</class >
62
65
63
- </hibernate-mapping >
66
+ </hibernate-mapping >
Original file line number Diff line number Diff line change @@ -848,6 +848,27 @@ public async Task ContainsOnPersistedCollectionAsync()
848
848
Assert . That ( result . SerialNumber , Is . EqualTo ( "1121" ) ) ;
849
849
}
850
850
851
+ [ Test ]
852
+ public async Task CanCompareAggregateResultAsync ( )
853
+ {
854
+ if ( ! Dialect . SupportsScalarSubSelects )
855
+ {
856
+ Assert . Ignore ( Dialect . GetType ( ) . Name + " does not support scalar sub-queries" ) ;
857
+ }
858
+
859
+ await ( session . Query < Customer > ( )
860
+ . Select ( o => new AggregateDate { Id = o . CustomerId , MaxDate = o . Orders . Max ( l => l . RequiredOrderDate ) } )
861
+ . Where ( o => o . MaxDate <= DateTime . Today && o . MaxDate >= DateTime . Today )
862
+ . ToListAsync ( ) ) ;
863
+ }
864
+
865
+ private class AggregateDate
866
+ {
867
+ public string Id { get ; set ; }
868
+
869
+ public DateTime ? MaxDate { get ; set ; }
870
+ }
871
+
851
872
private static List < object [ ] > CanUseCompareInQueryDataSource ( )
852
873
{
853
874
return new List < object [ ] >
Original file line number Diff line number Diff line change @@ -849,6 +849,27 @@ public void ContainsOnPersistedCollection()
849
849
Assert . That ( result . SerialNumber , Is . EqualTo ( "1121" ) ) ;
850
850
}
851
851
852
+ [ Test ]
853
+ public void CanCompareAggregateResult ( )
854
+ {
855
+ if ( ! Dialect . SupportsScalarSubSelects )
856
+ {
857
+ Assert . Ignore ( Dialect . GetType ( ) . Name + " does not support scalar sub-queries" ) ;
858
+ }
859
+
860
+ session . Query < Customer > ( )
861
+ . Select ( o => new AggregateDate { Id = o . CustomerId , MaxDate = o . Orders . Max ( l => l . RequiredOrderDate ) } )
862
+ . Where ( o => o . MaxDate <= DateTime . Today && o . MaxDate >= DateTime . Today )
863
+ . ToList ( ) ;
864
+ }
865
+
866
+ private class AggregateDate
867
+ {
868
+ public string Id { get ; set ; }
869
+
870
+ public DateTime ? MaxDate { get ; set ; }
871
+ }
872
+
852
873
private static List < object [ ] > CanUseCompareInQueryDataSource ( )
853
874
{
854
875
return new List < object [ ] >
Original file line number Diff line number Diff line change @@ -317,8 +317,8 @@ protected HqlTreeNode VisitBinaryExpression(BinaryExpression expression)
317
317
var rightType = GetExpressionType ( expression . Right ) ;
318
318
if ( leftType != null && leftType == rightType )
319
319
{
320
- _notCastableExpressions . Add ( expression . Left , leftType ) ;
321
- _notCastableExpressions . Add ( expression . Right , rightType ) ;
320
+ _notCastableExpressions [ expression . Left ] = leftType ;
321
+ _notCastableExpressions [ expression . Right ] = rightType ;
322
322
}
323
323
324
324
if ( expression . NodeType == ExpressionType . Equal )
You can’t perform that action at this time.
0 commit comments