Common declarations:
private static void PrepareProductHistory(Products products)
{
var productHistory = ToTable<Products>(PRODUCT_HISTORY);
SELECT(products).INTO(productHistory);
FROM(products);
Semicolon();
}
var rows = DbContext.Database.Execute((Products products) =>
{
PrepareProductHistory(products);
var productHistory = ToTable<Products>(PRODUCT_HISTORY);
DELETE(TOP(21)).FROM(productHistory);
});
Console.WriteLine($"{rows} rows affected");
var rows = DbContext.Database.Execute((Products products) =>
{
PrepareProductHistory(products);
var productHistory = ToTable<Products>(PRODUCT_HISTORY);
DELETE(TOP(5).PERCENT()).FROM(productHistory);
});
Console.WriteLine($"{rows} rows affected");
var rows = DbContext.Database.Execute((Products products) =>
{
PrepareProductHistory(products);
var productHistory = ToTable<Products>(PRODUCT_HISTORY);
DELETE().FROM(productHistory);
WHERE(productHistory.ModelYear == 2017);
});
Console.WriteLine($"{rows} rows affected");
var rows = DbContext.Database.Execute((Products products) =>
{
PrepareProductHistory(products);
var productHistory = ToTable<Products>(PRODUCT_HISTORY);
DELETE().FROM(productHistory);
});
Console.WriteLine($"{rows} rows affected");