mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 23:03:58 +00:00
Initial commit
This commit is contained in:
parent
01d6ccf414
commit
dd097904c2
54 changed files with 37154 additions and 0 deletions
48
vscode/Chapter10/WorkingWithEFCore/Program.cs
Normal file
48
vscode/Chapter10/WorkingWithEFCore/Program.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using Packt.Shared;
|
||||
|
||||
/*
|
||||
Northwind db = new();
|
||||
WriteLine($"Provider: {db.Database.ProviderName}");
|
||||
*/
|
||||
|
||||
// QueryingCategories();
|
||||
|
||||
//FilteredIncludes();
|
||||
|
||||
//QueryingProducts();
|
||||
|
||||
//QueryingWithLike();
|
||||
|
||||
//GetRandomProduct();
|
||||
|
||||
var resultAdd = AddProduct(categoryId: 6,
|
||||
productName: "Bob's Burgers", price: 500M);
|
||||
|
||||
if (resultAdd.affected == 1)
|
||||
{
|
||||
WriteLine("Add product successful.");
|
||||
}
|
||||
|
||||
ListProducts(productIdToHighlight: resultAdd.productId);
|
||||
|
||||
var resultUpdate = IncreaseProductPrice(
|
||||
productNameStartsWith: "Bob", amount: 20M);
|
||||
|
||||
if (resultUpdate.affected == 1)
|
||||
{
|
||||
WriteLine("Increase product price successful.");
|
||||
}
|
||||
|
||||
ListProducts(productIdToHighlight: resultUpdate.productId);
|
||||
|
||||
WriteLine("About to delete all products whose name starts with Bob.");
|
||||
Write("Press Enter to continue: ");
|
||||
if (ReadKey(intercept: true).Key == ConsoleKey.Enter)
|
||||
{
|
||||
int deleted = DeleteProducts(productNameStartsWith: "Bob");
|
||||
WriteLine($"{deleted} product(s) were deleted.");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine("Delete was cancelled.");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue