This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT R.Id, | |
C.Name, | |
R.Start, | |
R.Finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function areSomeNumberOfConsecutiveItemsPresentInArray( | |
targetNumberOfConsecutiveItems: number, | |
array: unknown[] | |
) { | |
let numberOfConsecutiveFound = 1 | |
let previousItem: unknown = {} | |
for (const currentItem of array) { | |
if (currentItem && currentItem === previousItem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function areSomeNumberOfConsecutiveItemsPresentInArray( | |
targetNumberOfConsecutiveItems: number, | |
array: unknown[] | |
) { | |
let numberOfConsecutiveFound = 1 | |
let previousItem: unknown = {} | |
for (const currentItem of array) { | |
if (currentItem && currentItem === previousItem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |