1
+ // Copyright 2021-present MongoDB Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ using System . Linq ;
16
+ using Microsoft . EntityFrameworkCore ;
17
+ using MongoDB . Analyzer . Tests . Common . DataModel ;
18
+ using MongoDB . Driver ;
19
+
20
+ namespace MongoDB . Analyzer . Tests . Common . TestCases . EF ;
21
+
22
+ public sealed class NotSupportedEFExpressions : TestCasesBase
23
+ {
24
+ [ NotSupportedEF ( "Byte array type is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
25
+ [ NotSupportedEF ( "Byte array type is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
26
+ [ NotSupportedEF ( "Byte array type is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
27
+ [ NotSupportedEF ( "Byte array type is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
28
+ public void ByteArrayProperties ( )
29
+ {
30
+ var dbContextOptions = new DbContextOptionsBuilder < DbContextUnsupportedEFExpressions > ( ) ;
31
+ var db = new DbContextUnsupportedEFExpressions ( dbContextOptions . Options ) ;
32
+ _ = db . SimpleTypesArraysHolder . Where ( s => s . ByteArray . Length == 1 ) ;
33
+ _ = db . SimpleTypesArraysHolder . Where ( s => s . IntArray . Length == 1 ) . Where ( s => s . IntArray . Length == 1 ) . Where ( s => s . ByteArray . Length == 1 ) ;
34
+ _ = db . SimpleTypesArraysHolder . Where ( s => s . IntArray . Length == 1 ) . Where ( s => s . ByteArray . Length == 1 ) . Where ( s => s . IntArray . Length == 1 ) ;
35
+ _ = db . SimpleTypesArraysHolder . Where ( s => s . ByteArray . Length == 1 ) . Where ( s => s . IntArray . Length == 1 ) . Where ( s => s . IntArray . Length == 1 ) ;
36
+ }
37
+
38
+ [ NotSupportedEF ( "GroupBy is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
39
+ [ NotSupportedEF ( "GroupBy is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
40
+ [ NotSupportedEF ( "GroupBy is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
41
+ [ NotSupportedEF ( "GroupBy is not supported by this version of the EF provider." , DriverVersions . Linq3OrGreater ) ]
42
+ public void GroupBy ( )
43
+ {
44
+ var dbContextOptions = new DbContextOptionsBuilder < DbContextUnsupportedEFExpressions > ( ) ;
45
+ var db = new DbContextUnsupportedEFExpressions ( dbContextOptions . Options ) ;
46
+ var users_query = db . Users . GroupBy ( u => u . Address ) ;
47
+ var customers_query = db . Customers . GroupBy ( c => c . LastName ) ;
48
+ _ = db . Users . Where ( u => u . Age == 21 ) . GroupBy ( u => u . Address ) ;
49
+ _ = db . Users . OrderBy ( u => u . Age ) . ThenBy ( u => u . Height ) . GroupBy ( u => u . Address ) ;
50
+ }
51
+ }
52
+
53
+ public class DbContextUnsupportedEFExpressions : DbContext
54
+ {
55
+ public DbSet < SimpleTypesArraysHolder > SimpleTypesArraysHolder { get ; set ; }
56
+ public DbSet < User > Users { get ; set ; }
57
+ public DbSet < Customer > Customers { get ; set ; }
58
+
59
+ public DbContextUnsupportedEFExpressions ( DbContextOptions options ) : base ( options )
60
+ {
61
+ }
62
+
63
+ protected override void OnModelCreating ( ModelBuilder modelBuilder )
64
+ {
65
+ base . OnModelCreating ( modelBuilder ) ;
66
+ }
67
+ }
0 commit comments