File tree Expand file tree Collapse file tree 5 files changed +51
-4
lines changed
NHibernate.DomainModel/Northwind Expand file tree Collapse file tree 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
4747 set { _orderDate = value ; }
4848 }
4949
50+ public virtual DateTime RequiredOrderDate { get ; set ; }
51+
5052 public virtual DateTime ? RequiredDate
5153 {
5254 get { return _requiredDate ; }
@@ -106,4 +108,4 @@ public virtual void RemoveOrderLine(OrderLine orderLine)
106108 }
107109 }
108110 }
109- }
111+ }
Original file line number Diff line number Diff line change 1717 <property name =" OrderDate" column =" OrderDate" type =" DateTime"
1818 access=" field.camelcase-underscore" />
1919
20+
21+ <property name =" RequiredOrderDate" formula =" OrderDate" insert =" false" update =" false" />
22+
2023 <property name =" RequiredDate" column =" RequiredDate" type =" DateTime"
2124 access=" field.camelcase-underscore" />
2225
6063
6164 </class >
6265
63- </hibernate-mapping >
66+ </hibernate-mapping >
Original file line number Diff line number Diff line change @@ -848,6 +848,27 @@ public async Task ContainsOnPersistedCollectionAsync()
848848 Assert . That ( result . SerialNumber , Is . EqualTo ( "1121" ) ) ;
849849 }
850850
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+
851872 private static List < object [ ] > CanUseCompareInQueryDataSource ( )
852873 {
853874 return new List < object [ ] >
Original file line number Diff line number Diff line change @@ -849,6 +849,27 @@ public void ContainsOnPersistedCollection()
849849 Assert . That ( result . SerialNumber , Is . EqualTo ( "1121" ) ) ;
850850 }
851851
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+
852873 private static List < object [ ] > CanUseCompareInQueryDataSource ( )
853874 {
854875 return new List < object [ ] >
Original file line number Diff line number Diff line change @@ -317,8 +317,8 @@ protected HqlTreeNode VisitBinaryExpression(BinaryExpression expression)
317317 var rightType = GetExpressionType ( expression . Right ) ;
318318 if ( leftType != null && leftType == rightType )
319319 {
320- _notCastableExpressions . Add ( expression . Left , leftType ) ;
321- _notCastableExpressions . Add ( expression . Right , rightType ) ;
320+ _notCastableExpressions [ expression . Left ] = leftType ;
321+ _notCastableExpressions [ expression . Right ] = rightType ;
322322 }
323323
324324 if ( expression . NodeType == ExpressionType . Equal )
You can’t perform that action at this time.
0 commit comments