1111using NUnit . Framework ;
1212using Xtensive . Core ;
1313using Xtensive . Orm . Configuration ;
14- using Xtensive . Orm . Tests . Issues . IssueJira0615_IncorrectComparisonWithLocalEntityModels ;
14+ using Xtensive . Orm . Tests . Issues . IssueJira0615_IncorrectComparisonWithLocalEntityModel ;
1515
1616namespace Xtensive . Orm . Tests . Issues
1717{
@@ -331,6 +331,7 @@ public void FilterByAlreadyExistedCreatedEntity()
331331 } )
332332 . OrderBy ( t => t . V2 )
333333 . ToArray ( ) ;
334+
334335 var expected = session . Query . All < PickingProductRequirement > ( )
335336 . AsEnumerable ( )
336337 . Select (
@@ -348,10 +349,43 @@ public void FilterByAlreadyExistedCreatedEntity()
348349 Assert . That ( results . SequenceEqual ( expected ) , Is . True ) ;
349350 }
350351 }
352+
353+ [ Test ]
354+ public void FilterByAlreadyExistedCreatedEntityReduced ( )
355+ {
356+ using ( var session = Domain . OpenSession ( ) )
357+ using ( var transaction = session . OpenTransaction ( ) ) {
358+ var sharedFlow = session . Query . All < LogisticFlow > ( ) . First ( f => f . ID == 1000 ) ;
359+
360+ var margin = 2 ;
361+ var results = session . Query . All < PickingProductRequirement > ( )
362+ . Select (
363+ p => new {
364+ V2 = ( int ) ( p . InventoryAction . LogisticFlow == sharedFlow ? margin : 1 )
365+ } )
366+ . OrderBy ( t => t . V2 )
367+ . ToArray ( ) ;
368+
369+ var expected = session . Query . All < PickingProductRequirement > ( )
370+ . AsEnumerable ( )
371+ . Select (
372+ p => new {
373+ V2 = ( int ) ( p . InventoryAction . LogisticFlow == sharedFlow ? margin : 1 )
374+ } )
375+ . OrderBy ( t => t . V2 )
376+ . ToArray ( ) ;
377+
378+ Assert . That ( expected . Length , Is . EqualTo ( 4 ) ) ;
379+ Assert . That ( results . Length , Is . EqualTo ( expected . Length ) ) ;
380+ Assert . That ( results . Skip ( 1 ) . All ( a => a . V2 == 2 ) , Is . True ) ;
381+ Assert . That ( results [ 0 ] . V2 , Is . EqualTo ( 1 ) ) ;
382+ Assert . That ( results . SequenceEqual ( expected ) , Is . True ) ;
383+ }
384+ }
351385 }
352386}
353387
354- namespace Xtensive . Orm . Tests . Issues . IssueJira0615_IncorrectComparisonWithLocalEntityModels
388+ namespace Xtensive . Orm . Tests . Issues . IssueJira0615_IncorrectComparisonWithLocalEntityModel
355389{
356390 [ HierarchyRoot ]
357391 public class InventoryAction : MesObject
0 commit comments