2022-03-05 16:45:55 +01:00
|
|
|
|
using Packt.Shared;
|
|
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
|
2022-03-05 16:45:55 +01:00
|
|
|
|
Northwind db = new();
|
|
|
|
|
|
WriteLine($"Provider: {db.Database.ProviderName}");
|
2022-09-19 15:16:37 +02:00
|
|
|
|
|
2022-03-05 16:45:55 +01:00
|
|
|
|
|
|
|
|
|
|
// QueryingCategories();
|
|
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
// FilteredIncludes();
|
2022-03-05 16:45:55 +01:00
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
// QueryingProducts();
|
2022-03-05 16:45:55 +01:00
|
|
|
|
|
|
|
|
|
|
//QueryingWithLike();
|
|
|
|
|
|
|
|
|
|
|
|
//GetRandomProduct();
|
|
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
/*
|
2022-03-05 16:45:55 +01:00
|
|
|
|
var resultAdd = AddProduct(categoryId: 6,
|
|
|
|
|
|
productName: "Bob's Burgers", price: 500M);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultAdd.affected == 1)
|
|
|
|
|
|
{
|
2022-09-19 15:16:37 +02:00
|
|
|
|
WriteLine($"Add product successful with ID: {resultAdd.productId}.");
|
2022-03-05 16:45:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
ListProducts(productIdsToHighlight: new[] { resultAdd.productId });
|
|
|
|
|
|
*/
|
2022-03-05 16:45:55 +01:00
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
/*
|
2022-03-05 16:45:55 +01:00
|
|
|
|
var resultUpdate = IncreaseProductPrice(
|
|
|
|
|
|
productNameStartsWith: "Bob", amount: 20M);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultUpdate.affected == 1)
|
2022-09-19 15:16:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
WriteLine($"Increase price success for ID: {resultUpdate.productId}.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ListProducts(productIdsToHighlight: new[] { resultUpdate.productId });
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
var resultUpdateBetter = IncreaseProductPricesBetter(
|
|
|
|
|
|
productNameStartsWith: "Bob", amount: 20M);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultUpdateBetter.affected > 0)
|
2022-03-05 16:45:55 +01:00
|
|
|
|
{
|
|
|
|
|
|
WriteLine("Increase product price successful.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
ListProducts(productIdsToHighlight: resultUpdateBetter.productIds);
|
|
|
|
|
|
*/
|
2022-03-05 16:45:55 +01:00
|
|
|
|
|
2022-09-19 15:16:37 +02:00
|
|
|
|
/*
|
2022-03-05 16:45:55 +01:00
|
|
|
|
WriteLine("About to delete all products whose name starts with Bob.");
|
2022-09-19 15:16:37 +02:00
|
|
|
|
Write("Press Enter to continue or any other key to exit: ");
|
2022-03-05 16:45:55 +01:00
|
|
|
|
if (ReadKey(intercept: true).Key == ConsoleKey.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
int deleted = DeleteProducts(productNameStartsWith: "Bob");
|
|
|
|
|
|
WriteLine($"{deleted} product(s) were deleted.");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-07-24 21:31:20 +02:00
|
|
|
|
WriteLine("Delete was canceled.");
|
2022-09-19 15:16:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
WriteLine("About to delete all products whose name starts with Bob.");
|
|
|
|
|
|
Write("Press Enter to continue or any other key to exit: ");
|
|
|
|
|
|
if (ReadKey(intercept: true).Key == ConsoleKey.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
int deleted = DeleteProductsBetter(productNameStartsWith: "Bob");
|
|
|
|
|
|
WriteLine($"{deleted} product(s) were deleted.");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
WriteLine("Delete was canceled.");
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|