You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
new Product(id: "baaa4d2d-5ebe-45fb-9a5c-d06876f408e0", category: new Category(name: "Components, Road Frames"), sku: "FR-R72R-60", name: """ML Road Frame - Red, 60""", description: """The product called "ML Road Frame - Red, 60".""", price: 594.83000000000004m),
276
+
new Product(id: "bd43543e-024c-4cda-a852-e29202310214", category: new Category(name: "Components, Forks"), sku: "FK-5136", name: """ML Fork""", description: """The product called "ML Fork".""", price: 175.49000000000001m),
277
+
...
278
278
};
279
279
}
280
280
```
@@ -286,20 +286,25 @@ Now, you'll create a new ASP.NET web application using a sample project template
286
286
{ }
287
287
```
288
288
289
-
1. Finally, navigate to and open the **Models/Product.cs**file. Observe the record type defined inthis file. This type will be used in queries throughout this tutorial.
289
+
1. Finally, navigate to and open the **Models/Product.cs**and **Models/Category.cs** files. Observe the record types defined ineach file. These types will be used in queries throughout this tutorial.
290
290
291
291
```csharp
292
292
public record Product(
293
293
string id,
294
-
string categoryId,
295
-
string categoryName,
294
+
Category category,
296
295
string sku,
297
296
string name,
298
297
string description,
299
298
decimal price
300
299
);
301
300
```
302
301
302
+
```csharp
303
+
public record Category(
304
+
string name
305
+
);
306
+
```
307
+
303
308
## Query data using the .NET SDK
304
309
305
310
Next, you'll add the Azure SDK for .NET to this sample project and use the library to query data from the API for NoSQL container.
@@ -438,26 +443,24 @@ Next, you'll add the Azure SDK for .NET to this sample project and use the libra
438
443
string sql = """
439
444
SELECT
440
445
p.id,
441
-
p.categoryId,
442
-
p.categoryName,
443
-
p.sku,
444
446
p.name,
447
+
p.category,
448
+
p.sku,
445
449
p.description,
446
-
p.price,
447
-
p.tags
450
+
p.price
448
451
FROM products p
449
-
JOIN t IN p.tags
450
-
WHERE t.name = @tagFilter
452
+
JOIN tag IN p.tags
453
+
WHERE STRINGEQUALS(tag, @tagFilter, true)
451
454
""";
452
455
```
453
456
454
-
1. Create a new `QueryDefinition` variable named `query` passing in the `sql` string as the only query parameter. Also, use the `WithParameter` fluid method to apply the value `Tag-75` to the `@tagFilter` parameter.
457
+
1. Create a new `QueryDefinition` variable named `query` passing in the `sql` string as the only query parameter. Also, use the `WithParameter` fluid method to apply the value `red` to the `@tagFilter` parameter.
455
458
456
459
```csharp
457
460
var query = new QueryDefinition(
458
461
query: sql
459
462
)
460
-
.WithParameter("@tagFilter", "Tag-75");
463
+
.WithParameter("@tagFilter", "red");
461
464
```
462
465
463
466
1. Use the `GetItemQueryIterator<>` generic method and the `query` variable to create an iterator that gets data from Azure Cosmos DB. Store the iterator in a variable named `feed`. Wrap this entire expression in a using statement to dispose the iterator later.
0 commit comments