This file contains hidden or 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
| public abstract class HotelBookingTemplate | |
| { | |
| // Template Method | |
| public void BookRoom() | |
| { | |
| SelectRoom(); | |
| ProcessPayment(); | |
| ApplyDiscount(); | |
| SendBookingConfirmation(); | |
| } |
This file contains hidden or 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
| using Microsoft.AspNetCore.RateLimiting; | |
| using System.Threading.RateLimiting; | |
| var builder = WebApplication.CreateBuilder(args); | |
| builder.Services.AddRateLimiter(options => | |
| { | |
| // 1. Fixed Window Limiter (20 requests per 2 minutes) | |
| // ----------------------------------------------- | |
| // |----------------- 2 min -----------------| |
This file contains hidden or 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
| using Microsoft.EntityFrameworkCore.Diagnostics; | |
| using System.Data.Common; | |
| namespace EntityFrameworkExamples; | |
| public class SlowQueryInterceptor(ILogger<SlowQueryInterceptor> logger) : DbCommandInterceptor | |
| { | |
| private const int _slowQueryThresholdInMilliseconds = 5; //from config | |
| public override DbDataReader ReaderExecuted( |
This file contains hidden or 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
| // 1. Order Entity | |
| namespace VerticalSliceExample.Domain; | |
| public class Order | |
| { | |
| public int Id { get; set; } | |
| public int CustomerId { get; set; } | |
| public Dictionary<int, int> Products { get; set; } = new(); // ProductId -> Quantity | |
| public decimal TotalAmount { get; private set; } | |
| public DateTime CreatedAt { get; set; } = DateTime.UtcNow; |
This file contains hidden or 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
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Columns; | |
| using BenchmarkDotNet.Configs; | |
| using BenchmarkDotNet.Environments; | |
| using BenchmarkDotNet.Jobs; | |
| using BenchmarkDotNet.Reports; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; |
This file contains hidden or 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
| USE TestDB | |
| GO | |
| DECLARE @DatabaseName VARCHAR(100) | |
| DECLARE @SchemaName VARCHAR(100) | |
| DECLARE @TableName VARCHAR(100) | |
| DECLARE @ColumnName VARCHAR(100) | |
| DECLARE @FullyQualifiedTableName VARCHAR(500) | |
| --Create Temp Table to Save Results |
This file contains hidden or 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 'ALTER TABLE ' + QUOTENAME(ss.name) + '.' + QUOTENAME(st.name) + ' ADD created_date DATETIME NULL;' | |
| FROM sys.tables st | |
| INNER JOIN sys.schemas ss on st.[schema_id] = ss.[schema_id] | |
| WHERE st.is_ms_shipped = 0 | |
| AND NOT EXISTS ( | |
| SELECT 1 | |
| FROM sys.columns sc | |
| WHERE sc.[object_id] = st.[object_id] | |
| AND sc.name = 'created_date' | |
| ) |
This file contains hidden or 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
| { | |
| rateLimit { | |
| limit | |
| remaining | |
| used | |
| resetAt | |
| } | |
| user(login: "davepcallan") { | |
| name | |
| bio |
This file contains hidden or 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
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Columns; | |
| using BenchmarkDotNet.Configs; | |
| using BenchmarkDotNet.Jobs; | |
| using BenchmarkDotNet.Reports; | |
| using BenchmarkDotNet.Environments; | |
| namespace ExceptionBenchmark | |
| { | |
| [Config(typeof(Config))] |
This file contains hidden or 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
| -- Create Test Table | |
| CREATE TABLE TruncateTest (ID INT) | |
| INSERT INTO TruncateTest (ID) | |
| SELECT 1 | |
| UNION ALL | |
| SELECT 2 | |
| UNION ALL | |
| SELECT 3 | |
| GO | |
| -- Check the data before truncate |