1
1
---
2
- title : LINQ to SQL translation
2
+ title : LINQ to NoSQL translation
3
3
titleSuffix : Azure Cosmos DB for NoSQL
4
- description : Learn the LINQ operators supported and how the LINQ queries are mapped to SQL queries in Azure Cosmos DB.
4
+ description : Learn the LINQ operators supported and how the LINQ queries are mapped to NoSQL queries in Azure Cosmos DB.
5
5
author : jcodella
6
6
ms.author : jacodel
7
7
ms.reviewer : sidandrews
@@ -12,11 +12,11 @@ ms.date: 07/31/2023
12
12
ms.custom : query-reference
13
13
---
14
14
15
- # LINQ to SQL translation in Azure Cosmos DB for NoSQL
15
+ # LINQ to NoSQL translation in Azure Cosmos DB for NoSQL
16
16
17
17
[ !INCLUDE[ NoSQL] ( ../../includes/appliesto-nosql.md )]
18
18
19
- The Azure Cosmos DB query provider performs a best effort mapping from a LINQ query into an Azure Cosmos DB SQL query. If you want to get the SQL query that is translated from LINQ, use the ` ToString() ` method on the generated ` IQueryable ` object. The following description assumes a basic familiarity with [ LINQ] ( /dotnet/csharp/programming-guide/concepts/linq/introduction-to-linq-queries ) . In addition to LINQ, Azure Cosmos DB also supports [ Entity Framework Core] ( /ef/core/providers/cosmos/?tabs=dotnet-core-cli ) , which works with API for NoSQL.
19
+ The Azure Cosmos DB query provider performs a best effort mapping from a LINQ query into an Azure Cosmos DB for NoSQL query. If you want to get the NoSQL query that is translated from LINQ, use the ` ToString() ` method on the generated ` IQueryable ` object. The following description assumes a basic familiarity with [ LINQ] ( /dotnet/csharp/programming-guide/concepts/linq/introduction-to-linq-queries ) . In addition to LINQ, Azure Cosmos DB also supports [ Entity Framework Core] ( /ef/core/providers/cosmos/?tabs=dotnet-core-cli ) , which works with API for NoSQL.
20
20
21
21
> [ !NOTE]
22
22
> We recommend using the latest [ .NET SDK (` Microsoft.Azure.Cosmos ` ) version] ( https://www.nuget.org/packages/Microsoft.Azure.Cosmos/ )
@@ -93,10 +93,10 @@ while (setIterator.HasMoreResults)
93
93
94
94
## Supported LINQ operators
95
95
96
- The LINQ provider included with the SQL .NET SDK supports the following operators :
96
+ The LINQ provider included with the NoSQL .NET SDK supports the following operators :
97
97
98
98
- ** Select ** : Projections translate to [SELECT ](select .md ), including object construction .
99
- - ** Where ** : Filters translate to [WHERE ](where .md ), and support translation between `&& `, `|| `, and `! ` to the SQL operators
99
+ - ** Where ** : Filters translate to [WHERE ](where .md ), and support translation between `&& `, `|| `, and `! ` to the NoSQL operators
100
100
- ** SelectMany ** : Allows unwinding of arrays to the [JOIN ](join .md ) clause . Use to chain or nest expressions to filter on array elements .
101
101
- ** OrderBy ** and ** OrderByDescending ** : Translate to [ORDER BY ](order - by .md ) with ASC or DESC .
102
102
- ** Count ** , ** Sum ** , ** Min ** , ** Max ** , and ** Average ** operators for aggregation , and their async equivalents ** CountAsync ** , ** SumAsync ** , ** MinAsync ** , ** MaxAsync ** , and ** AverageAsync ** .
@@ -125,7 +125,7 @@ The syntax is `input.Select(x => f(x))`, where `f` is a scalar expression. The `
125
125
input .Select (family => family .parents [0 ].familyName );
126
126
```
127
127
128
- - ** SQL **
128
+ - ** NoSQL **
129
129
130
130
```sql
131
131
SELECT VALUE f .parents [0 ].familyName
@@ -140,7 +140,7 @@ The syntax is `input.Select(x => f(x))`, where `f` is a scalar expression. The `
140
140
input .Select (family => family .children [0 ].grade + c ); // c is an int variable
141
141
```
142
142
143
- - ** SQL **
143
+ - ** NoSQL **
144
144
145
145
```sql
146
146
SELECT VALUE f .children [0 ].grade + c
@@ -159,7 +159,7 @@ The syntax is `input.Select(x => f(x))`, where `f` is a scalar expression. The `
159
159
});
160
160
```
161
161
162
- - ** SQL **
162
+ - ** NoSQL **
163
163
164
164
```sql
165
165
SELECT VALUE {
@@ -179,7 +179,7 @@ The syntax is `input.SelectMany(x => f(x))`, where `f` is a scalar expression th
179
179
input .SelectMany (family => family .children );
180
180
```
181
181
182
- - ** SQL **
182
+ - ** NoSQL **
183
183
184
184
```sql
185
185
SELECT VALUE child
@@ -198,7 +198,7 @@ The syntax is `input.Where(x => f(x))`, where `f` is a scalar expression, which
198
198
input .Where (family => family .parents [0 ].familyName == " Wakefield" );
199
199
```
200
200
201
- - ** SQL **
201
+ - ** NoSQL **
202
202
203
203
```sql
204
204
SELECT *
@@ -216,7 +216,7 @@ The syntax is `input.Where(x => f(x))`, where `f` is a scalar expression, which
216
216
family .children [0 ].grade < 3 );
217
217
```
218
218
219
- - ** SQL **
219
+ - ** NoSQL **
220
220
221
221
```sql
222
222
SELECT *
@@ -225,7 +225,7 @@ The syntax is `input.Where(x => f(x))`, where `f` is a scalar expression, which
225
225
AND f .children [0 ].grade < 3
226
226
```
227
227
228
- ## Composite SQL queries
228
+ ## Composite NoSQL queries
229
229
230
230
You can compose the preceding operators to form more powerful queries . Since Azure Cosmos DB supports nested containers , you can concatenate or nest the composition .
231
231
@@ -242,7 +242,7 @@ The syntax is `input(.|.SelectMany())(.Select()|.Where())*`. A concatenated quer
242
242
.Where (parent => parent .familyName == " Wakefield" );
243
243
```
244
244
245
- - ** SQL **
245
+ - ** NoSQL **
246
246
247
247
```sql
248
248
SELECT *
@@ -259,7 +259,7 @@ The syntax is `input(.|.SelectMany())(.Select()|.Where())*`. A concatenated quer
259
259
.Select (family => family .parents [0 ].familyName );
260
260
```
261
261
262
- - ** SQL **
262
+ - ** NoSQL **
263
263
264
264
```sql
265
265
SELECT VALUE f .parents [0 ].familyName
@@ -276,7 +276,7 @@ The syntax is `input(.|.SelectMany())(.Select()|.Where())*`. A concatenated quer
276
276
Where (anon => anon .grade < 3 );
277
277
```
278
278
279
- - ** SQL **
279
+ - ** NoSQL **
280
280
281
281
```sql
282
282
SELECT *
@@ -293,7 +293,7 @@ The syntax is `input(.|.SelectMany())(.Select()|.Where())*`. A concatenated quer
293
293
.Where (parent => parents .familyName == " Wakefield" );
294
294
```
295
295
296
- - ** SQL **
296
+ - ** NoSQL **
297
297
298
298
```sql
299
299
SELECT *
@@ -316,7 +316,7 @@ A nested query applies the inner query to each element of the outer container. O
316
316
family .parents .Select (p => p .familyName ));
317
317
```
318
318
319
- - ** SQL **
319
+ - ** NoSQL **
320
320
321
321
```sql
322
322
SELECT VALUE p .familyName
@@ -333,7 +333,7 @@ A nested query applies the inner query to each element of the outer container. O
333
333
family .children .Where (child => child .familyName == " Jeff" ));
334
334
```
335
335
336
- - ** SQL **
336
+ - ** NoSQL **
337
337
338
338
```sql
339
339
SELECT *
@@ -351,7 +351,7 @@ A nested query applies the inner query to each element of the outer container. O
351
351
child => child .familyName == family .parents [0 ].familyName ));
352
352
```
353
353
354
- - ** SQL **
354
+ - ** NoSQL **
355
355
356
356
```sql
357
357
SELECT *
0 commit comments