@@ -31,17 +31,33 @@ public QueryLoggingJetTest(NorthwindQueryJetFixture<NoopModelCustomizer> fixture
31
31
[ ConditionalFact ]
32
32
public virtual void Queryable_simple ( )
33
33
{
34
- using ( var context = CreateContext ( ) )
35
- {
36
- var customers
37
- = context . Set < Customer > ( )
38
- . ToList ( ) ;
34
+ using var context = CreateContext ( ) ;
35
+ var customers
36
+ = context . Set < Customer > ( )
37
+ . ToList ( ) ;
39
38
40
- Assert . NotNull ( customers ) ;
41
- Assert . StartsWith (
42
- "queryContext => new QueryingEnumerable<Customer>(" ,
43
- Fixture . TestSqlLoggerFactory . Log [ 0 ] . Message ) ;
44
- }
39
+ Assert . NotNull ( customers ) ;
40
+
41
+ Assert . StartsWith (
42
+ "Compiling query expression: " ,
43
+ Fixture . TestSqlLoggerFactory . Log [ 0 ] . Message ) ;
44
+ Assert . StartsWith (
45
+ "Generated query execution expression: " + Environment . NewLine + "'queryContext => new SingleQueryingEnumerable<Customer>(" ,
46
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
47
+ }
48
+
49
+ [ ConditionalFact ]
50
+ public virtual void Queryable_simple_split ( )
51
+ {
52
+ using var context = CreateContext ( ) ;
53
+ var customers
54
+ = context . Set < Customer > ( ) . AsSplitQuery ( )
55
+ . ToList ( ) ;
56
+
57
+ Assert . NotNull ( customers ) ;
58
+ Assert . StartsWith (
59
+ "Generated query execution expression: " + Environment . NewLine + "'queryContext => new SplitQueryingEnumerable<Customer>(" ,
60
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
45
61
}
46
62
47
63
[ ConditionalFact ]
@@ -66,78 +82,88 @@ var customers
66
82
}
67
83
}
68
84
69
- [ ConditionalFact ( Skip = "Issue#17498" ) ]
70
- public virtual void Query_with_ignored_include_should_log_warning ( )
85
+ [ ConditionalFact ]
86
+ public virtual void Include_navigation ( )
71
87
{
72
- using ( var context = CreateContext ( ) )
73
- {
74
- var customers
75
- = context . Customers
76
- . Include ( c => c . Orders )
77
- . Select ( c => c . CustomerID )
78
- . ToList ( ) ;
88
+ using var context = CreateContext ( ) ;
89
+ var customers
90
+ = context . Set < Customer > ( )
91
+ . Where ( c => c . CustomerID == "ALFKI" )
92
+ . Include ( c => c . Orders )
93
+ . ToList ( ) ;
79
94
80
- Assert . NotNull ( customers ) ;
81
- Assert . Contains (
82
- #pragma warning disable CS0612 // Type or member is obsolete
83
- CoreResources . LogNavigationBaseIncludeIgnored ( new TestLogger < JetLoggingDefinitions > ( ) ) . GenerateMessage ( "`c`.Orders" ) ,
84
- Fixture . TestSqlLoggerFactory . Log . Select ( l => l . Message ) ) ;
85
- #pragma warning restore CS0612 // Type or member is obsolete
86
- }
95
+ Assert . NotNull ( customers ) ;
96
+
97
+ Assert . Equal (
98
+ "Including navigation: 'Customer.Orders'." ,
99
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
87
100
}
88
101
89
- [ ConditionalFact ( Skip = "Issue#17498" ) ]
90
- public virtual void Include_navigation ( )
102
+ [ ConditionalFact ]
103
+ public virtual void Skip_without_order_by ( )
91
104
{
92
- using ( var context = CreateContext ( ) )
93
- {
94
- var customers
95
- = context . Set < Customer > ( )
96
- . Include ( c => c . Orders )
97
- . ToList ( ) ;
105
+ using var context = CreateContext ( ) ;
106
+ var customers = context . Set < Customer > ( ) . Skip ( 85 ) . ToList ( ) ;
98
107
99
- Assert . NotNull ( customers ) ;
108
+ Assert . NotNull ( customers ) ;
100
109
101
- Assert . Equal (
102
- "Compiling query model: " + _eol + "'(from Customer c in DbSet<Customer>" + _eol + @"select `c`).Include(""Orders"")'"
103
- ,
104
- Fixture . TestSqlLoggerFactory . Log [ 0 ] . Message ) ;
105
- Assert . Equal (
106
- "Including navigation: '`c`.Orders'"
107
- ,
108
- Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
109
- Assert . StartsWith (
110
- "Optimized query model: "
111
- + _eol
112
- + "'from Customer c in DbSet<Customer>"
113
- + _eol
114
- + @"order by EF.Property(?`c`?, ""CustomerID"") asc"
115
- + _eol
116
- + "select Customer _Include("
117
- ,
118
- Fixture . TestSqlLoggerFactory . Log [ 2 ] . Message ) ;
119
- }
110
+ Assert . Equal (
111
+ CoreResources . LogRowLimitingOperationWithoutOrderBy ( new TestLogger < JetLoggingDefinitions > ( ) ) . GenerateMessage ( ) ,
112
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
120
113
}
121
114
122
- [ ConditionalFact ( Skip = "Issue #16752" ) ]
123
- public virtual void GroupBy_Include_collection_ignored ( )
115
+ [ ConditionalFact ]
116
+ public virtual void Take_without_order_by ( )
124
117
{
125
- using ( var context = CreateContext ( ) )
126
- {
127
- var orders = context . Orders
128
- . GroupBy ( o => o . OrderID )
129
- . Select ( g => g . OrderBy ( o => o . OrderID ) . FirstOrDefault ( ) )
130
- . Include ( o => o . OrderDetails )
131
- . ToList ( ) ;
118
+ using var context = CreateContext ( ) ;
119
+ var customers = context . Set < Customer > ( ) . Take ( 5 ) . ToList ( ) ;
132
120
133
- Assert . NotNull ( orders ) ;
134
- Assert . Contains (
135
- #pragma warning disable CS0612 // Type or member is obsolete
136
- CoreResources . LogNavigationBaseIncludeIgnored ( new TestLogger < JetLoggingDefinitions > ( ) ) . GenerateMessage (
137
- #pragma warning restore CS0612 // Type or member is obsolete
138
- "{from Order o in `g` orderby `o`.OrderID asc select `o` => FirstOrDefault()}.OrderDetails" ) ,
139
- Fixture . TestSqlLoggerFactory . Log . Select ( l => l . Message ) ) ;
140
- }
121
+ Assert . NotNull ( customers ) ;
122
+
123
+ Assert . Equal (
124
+ CoreResources . LogRowLimitingOperationWithoutOrderBy ( new TestLogger < JetLoggingDefinitions > ( ) ) . GenerateMessage ( ) ,
125
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
126
+ }
127
+
128
+ [ ConditionalFact ]
129
+ public virtual void FirstOrDefault_without_filter_order_by ( )
130
+ {
131
+ using var context = CreateContext ( ) ;
132
+ var customer = context . Set < Customer > ( ) . FirstOrDefault ( ) ;
133
+
134
+ Assert . NotNull ( customer ) ;
135
+
136
+ Assert . Equal (
137
+ CoreResources . LogFirstWithoutOrderByAndFilter ( new TestLogger < JetLoggingDefinitions > ( ) ) . GenerateMessage ( ) ,
138
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
139
+ }
140
+
141
+ [ ConditionalFact ]
142
+ public virtual void Distinct_used_after_order_by ( )
143
+ {
144
+ using var context = CreateContext ( ) ;
145
+ var customers = context . Set < Customer > ( ) . OrderBy ( x => x . Address ) . Distinct ( ) . Take ( 5 ) . ToList ( ) ;
146
+
147
+ Assert . NotEmpty ( customers ) ;
148
+
149
+ Assert . Equal (
150
+ CoreResources . LogDistinctAfterOrderByWithoutRowLimitingOperatorWarning ( new TestLogger < JetLoggingDefinitions > ( ) )
151
+ . GenerateMessage ( ) ,
152
+ Fixture . TestSqlLoggerFactory . Log [ 1 ] . Message ) ;
153
+ }
154
+
155
+ [ ConditionalFact ]
156
+ public virtual void Include_collection_does_not_generate_warning ( )
157
+ {
158
+ using var context = CreateContext ( ) ;
159
+ var customer = context . Set < Customer > ( ) . Include ( e => e . Orders ) . AsSplitQuery ( ) . Single ( e => e . CustomerID == "ALFKI" ) ;
160
+
161
+ Assert . NotNull ( customer ) ;
162
+ Assert . Equal ( 6 , customer . Orders . Count ) ;
163
+
164
+ Assert . DoesNotContain (
165
+ CoreResources . LogRowLimitingOperationWithoutOrderBy ( new TestLogger < JetLoggingDefinitions > ( ) ) . GenerateMessage ( ) ,
166
+ Fixture . TestSqlLoggerFactory . Log . Select ( e => e . Message ) ) ;
141
167
}
142
168
143
169
[ ConditionalFact ]
0 commit comments