@@ -5697,5 +5697,120 @@ public virtual Task Multiple_conditionals_in_projection(bool async)
5697
5697
}
5698
5698
} ) ;
5699
5699
}
5700
+
5701
+ [ ConditionalTheory ]
5702
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5703
+ public virtual Task Composite_key_join_on_groupby_aggregate_projecting_only_grouping_key ( bool async )
5704
+ {
5705
+ return AssertQueryScalar (
5706
+ async ,
5707
+ ss => ss . Set < Level1 > ( )
5708
+ . Join (
5709
+ ss . Set < Level2 > ( ) . GroupBy ( g => g . Id % 3 ) . Select ( g => new { g . Key , Sum = g . Sum ( x => x . Id ) } ) ,
5710
+ o => new { o . Id , Condition = true } ,
5711
+ i => new { Id = i . Key , Condition = i . Sum > 10 , } ,
5712
+ ( o , i ) => i . Key ) ) ;
5713
+ }
5714
+
5715
+ [ ConditionalTheory ]
5716
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5717
+ public virtual Task Multiple_joins_groupby_predicate ( bool async )
5718
+ {
5719
+ return AssertQuery (
5720
+ async ,
5721
+ ss => from l1 in ss . Set < Level1 > ( )
5722
+ join l2 in ss . Set < Level2 > ( ) on l1 . Id equals l2 . Level1_Optional_Id into grouping1
5723
+ from l2 in grouping1 . DefaultIfEmpty ( )
5724
+ join x in ( from l3 in ss . Set < Level3 > ( )
5725
+ group l3 by l3 . Name into g
5726
+ select new { Key = g . Key , Count = g . Count ( ) } ) on l1 . Name equals x . Key into grouping2
5727
+ from x in grouping2 . DefaultIfEmpty ( )
5728
+ where l2 . Name != null || x . Count > 0
5729
+ select new { l1 . Id , l1 . Name , Foo = l2 == null ? "Foo" : "Bar" } ,
5730
+ elementSorter: e => ( e . Id , e . Name , e . Foo ) ) ;
5731
+ }
5732
+
5733
+ [ ConditionalTheory ]
5734
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5735
+ public virtual Task Collection_FirstOrDefault_property_accesses_in_projection ( bool async )
5736
+ {
5737
+ return AssertQuery (
5738
+ async ,
5739
+ ss => ss . Set < Level1 > ( )
5740
+ . Include ( x => x . OneToMany_Optional1 ) . ThenInclude ( x => x . OneToMany_Optional2 )
5741
+ . Where ( l1 => l1 . Id < 3 )
5742
+ . Select ( l1 => new
5743
+ {
5744
+ l1 . Id ,
5745
+ Pushdown = l1 . OneToMany_Optional1 . Where ( x => x . Name == "L2 02" ) . FirstOrDefault ( ) . Name
5746
+ } ) ) ;
5747
+ }
5748
+
5749
+ [ ConditionalTheory ]
5750
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5751
+ public virtual Task Collection_FirstOrDefault_entity_reference_accesses_in_projection ( bool async )
5752
+ {
5753
+ return AssertQuery (
5754
+ async ,
5755
+ ss => ss . Set < Level1 > ( )
5756
+ . Include ( x => x . OneToMany_Optional1 ) . ThenInclude ( x => x . OneToMany_Optional2 )
5757
+ . Where ( l1 => l1 . Id < 3 )
5758
+ . Select ( l1 => new
5759
+ {
5760
+ l1 . Id ,
5761
+ Pushdown = l1 . OneToMany_Optional1
5762
+ . Where ( x => x . Name == "L2 02" )
5763
+ . FirstOrDefault ( ) . OneToOne_Optional_FK2
5764
+ } ) ) ;
5765
+ }
5766
+
5767
+ [ ConditionalTheory ( Skip = "issue #22896" ) ]
5768
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5769
+ public virtual Task Collection_FirstOrDefault_entity_collection_accesses_in_projection ( bool async )
5770
+ {
5771
+ return AssertQuery (
5772
+ async ,
5773
+ ss => ss . Set < Level1 > ( )
5774
+ . Where ( l1 => l1 . Id < 2 )
5775
+ . Select ( l1 => new
5776
+ {
5777
+ l1 . Id ,
5778
+ Pushdown = l1 . OneToMany_Optional1
5779
+ . Where ( x => x . Name == "L2 02" )
5780
+ . FirstOrDefault ( ) . OneToMany_Optional2 . ToList ( )
5781
+ } ) ) ;
5782
+ }
5783
+
5784
+ [ ConditionalTheory ]
5785
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5786
+ public virtual Task Multiple_collection_FirstOrDefault_followed_by_member_access_in_projection ( bool async )
5787
+ {
5788
+ return AssertQuery (
5789
+ async ,
5790
+ ss => ss . Set < Level1 > ( )
5791
+ . Where ( l1 => l1 . Id < 2 )
5792
+ . Select ( l1 => new
5793
+ {
5794
+ l1 . Id ,
5795
+ Pushdown = l1 . OneToMany_Optional1
5796
+ . Where ( x => x . Name == "L2 02" )
5797
+ . FirstOrDefault ( ) . OneToMany_Optional2
5798
+ . OrderBy ( x => x . Id )
5799
+ . FirstOrDefault ( ) . Name
5800
+ } ) ) ;
5801
+ }
5802
+
5803
+ [ ConditionalTheory ]
5804
+ [ MemberData ( nameof ( IsAsyncData ) ) ]
5805
+ public virtual Task Projecting_columns_with_same_name_from_different_entities_making_sure_aliasing_works_after_Distinct ( bool async )
5806
+ {
5807
+ return AssertQuery (
5808
+ async ,
5809
+ ss => ( from l1 in ss . Set < Level1 > ( )
5810
+ join l2 in ss . Set < Level2 > ( ) on l1 . Id equals l2 . Level1_Optional_Id
5811
+ join l3 in ss . Set < Level3 > ( ) on l2 . Id equals l3 . Level2_Optional_Id
5812
+ select new { Id1 = l1 . Id , Id2 = l2 . Id , Id3 = l3 . Id , Name1 = l1 . Name , Name2 = l2 . Name } ) . Distinct ( ) . Select ( x => new { Foo = x . Id1 , Bar = x . Id2 , Baz = x . Id3 } ) . Take ( 10 ) ,
5813
+ elementSorter: e => ( e . Foo , e . Bar , e . Baz ) ) ;
5814
+ }
5700
5815
}
5701
5816
}
0 commit comments