Skip to content

Instantly share code, notes, and snippets.

var pendingMigrations = Database.GetPendingMigrations();
foreach (var pendingMigration in pendingMigrations)
{
Console.WriteLine("Script for migration " + pendingMigration.Name + ":");
var migrationScriptToPrint = pendingMigration.Script;
migrationScriptToPrint = migrationScriptToPrint.Replace("error", "err*r");
Console.WriteLine(migrationScriptToPrint)
SELECT ForthcomingBooking.Id,
ForthcomingBooking.Start,
ForthcomingBooking.Finish,
RoomType.Name,
BookingStatus.Name,
RoomSize.Name
FROM Booking ForthcomingBooking
INNER JOIN Lookup RoomType on RoomType.Id = ForthcomingBooking.RoomTypeId
INNER JOIN Lookup BookingStatus on BookingStatus.Id = ForthcomingBooking.StatusId
INNER JOIN Lookup RoomSize on RoomSize.Id = ForthcomingBooking.RoomeSizeId
SELECT B.Id,
B.Start,
B.Finish,
L1.Name,
L2.Name,
L3.Name
FROM Booking B
INNER JOIN Lookup L1 on L1.Id = B.RoomTypeId
INNER JOIN Lookup L2 on L2.Id = B.StatusId
INNER JOIN Lookup L3 on L3.Id = B.RoomeSizeId
select old_roles.principal_id,
old_roles.name,
old_roles.create_date
from sys.database_principals old_roles
where old_roles.create_date < DATEADD(DAY, -365, GETDATE())
and old_roles.type = 'R'
SELECT UnfulfilledReservation.Id,
PotentialGuest.Name,
UnfulfilledReservation.Start,
UnfulfilledReservation.Finish
FROM ReservationRequest UnfulfilledReservation
INNER JOIN Customer PotentialGuest ON PotentialGuest.CustomerId = UnfulfilledReservation.CustomerId
LEFT JOIN Booking ON Booking.CustomerId = PotentialGuest.CustomerId
WHERE UnfulfilledReservation.Start < GETDATE()
AND Booking.BookingId IS NULL
SELECT R.Id,
C.Name,
R.Start,
R.Finish
FROM ReservationRequest R
INNER JOIN Customer C ON C.Id = R.CustomerId
LEFT JOIN Booking B ON B.CustomerId = C.Id
WHERE R.Start < GETDATE()
AND B.BookingId IS NULL
SELECT R.Id,
C.Name,
R.Start,
R.Finish
function areSomeNumberOfConsecutiveItemsPresentInArray(
targetNumberOfConsecutiveItems: number,
array: unknown[]
) {
let numberOfConsecutiveFound = 1
let previousItem: unknown = {}
for (const currentItem of array) {
if (currentItem && currentItem === previousItem)
function areSomeNumberOfConsecutiveItemsPresentInArray(
targetNumberOfConsecutiveItems: number,
array: unknown[]
) {
let numberOfConsecutiveFound = 1
let previousItem: unknown = {}
for (const currentItem of array) {
if (currentItem && currentItem === previousItem)
// Could be a captured parameter or local variable
(DateTime? from, DateTime? to) dateRange = ...
return people.Where(ThePersonWasBornWithinTheDateRange);
// Local function, capturing dateRange.
bool ThePersonWasBornWithinTheDateRange(Person person) =>
(dateRange.to == null || person.DateOfBirth <= dateRange.to)
&& (dateRange.from == null || person.DateOfBirth >= dateRange.from)