File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -397,8 +397,18 @@ private void Bind<TIndex>() where TIndex : IIndex
397397
398398 private void Bind ( Type tIndex )
399399 {
400- if ( _queryState . GetBindings ( ) . Contains ( tIndex ) )
400+ var bindings = _queryState . GetBindings ( ) ;
401+ var bindingIndex = bindings . IndexOf ( tIndex ) ;
402+ if ( bindingIndex != - 1 )
401403 {
404+ // When a binding is reused it should be last to be correctly applied to a filter predicate.
405+ if ( bindingIndex != bindings . Count - 1 )
406+ {
407+ var binding = bindings [ bindingIndex ] ;
408+ bindings . RemoveAt ( bindingIndex ) ;
409+ bindings . Insert ( bindings . Count , binding ) ;
410+ }
411+
402412 return ;
403413 }
404414
Original file line number Diff line number Diff line change @@ -2039,6 +2039,49 @@ public async Task ShouldJoinReduceIndex()
20392039 }
20402040 }
20412041
2042+ [ Fact ]
2043+ public async Task JoinOrderShouldNotMatter ( )
2044+ {
2045+ _store . RegisterIndexes < PersonIndexProvider > ( ) ;
2046+ _store . RegisterIndexes < PersonAgeIndexProvider > ( ) ;
2047+
2048+ using ( var session = _store . CreateSession ( ) )
2049+ {
2050+ var bill = new Person
2051+ {
2052+ Firstname = "Bill" ,
2053+ Age = 1
2054+ } ;
2055+
2056+ var steve = new Person
2057+ {
2058+ Firstname = "Steve" ,
2059+ Age = 2
2060+ } ;
2061+
2062+ var paul = new Person
2063+ {
2064+ Firstname = "Scott" ,
2065+ Age = 2
2066+ } ;
2067+
2068+ session . Save ( bill ) ;
2069+ session . Save ( steve ) ;
2070+ session . Save ( paul ) ;
2071+
2072+ await session . SaveChangesAsync ( ) ;
2073+ }
2074+
2075+ using ( var session = _store . CreateSession ( ) )
2076+ {
2077+ Assert . Equal ( "Steve" , ( await session . Query ( ) . For < Person > ( )
2078+ . With < PersonByName > ( x => x . SomeName . StartsWith ( "S" ) )
2079+ . With < PersonByAge > ( x => x . Age == 2 )
2080+ . With < PersonByName > ( x => x . SomeName . EndsWith ( "e" ) )
2081+ . FirstOrDefaultAsync ( ) ) . Firstname ) ;
2082+ }
2083+ }
2084+
20422085 [ Fact ]
20432086 public async Task LoadingDocumentShouldNotDuplicateIndex ( )
20442087 {
You can’t perform that action at this time.
0 commit comments