Skip to content

Instantly share code, notes, and snippets.

View davepcallan's full-sized avatar

Dave Callan davepcallan

View GitHub Profile
@davepcallan
davepcallan / httpFileExample.http
Created March 7, 2026 08:49
Http file example showing how to create random ints and use request variables to store values from one request for use in later requests
@baseUrl = https://localhost:7053
@dummyInt = {{$randomInt 100000 999999}}
### Create Doctor (for appointment)
# @name createDoctor
POST {{baseUrl}}/doctors
Content-Type: application/json
{
"firstName": "Emma",
@davepcallan
davepcallan / CreatePatient.cs
Created February 28, 2026 11:48
Vertical Slice all in one file example for creating a patient
namespace MyApp.UseCases.Patients.CreatePatient;
// 1. ENDPOINT
[ApiController]
public sealed class Endpoint(Handler handler) : ControllerBase
{
[HttpPost("patients")]
public async Task<ActionResult<Response>> Post(Request req, CancellationToken ct)
{
var res = await handler.HandleAsync(req, ct);
@davepcallan
davepcallan / EntityFrameworkBatchSizeBenchmark.cs
Created November 25, 2025 15:49
Sample benchmark to test different Entity Framework batch sizes with the SQL Server provider
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Reports;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
namespace EntityFrameworkBenchmarks;
[Config(typeof(Config))]
@davepcallan
davepcallan / tracking-v-notracking.cs
Created November 25, 2025 15:42
Entity Framework Tracking v No-Tracking example BenchmarkDotNet benchmark
using System;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Microsoft.EntityFrameworkCore;
namespace Benchmarks;
[MemoryDiagnoser]
public class QueryTrackingBehavior
@davepcallan
davepcallan / SBvSJBenchmarks.cs
Created February 16, 2025 15:59
StringBuilder v different String.Join overloads
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using System;
using System.Collections.Generic;
using System.Text;
namespace Benchmarks
@davepcallan
davepcallan / StringConcatSimple.cs
Last active February 16, 2025 15:23
.NET 9 Simple String concatenation
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using System.Runtime.CompilerServices;
using System.Text;
namespace Benchmarks
{
@davepcallan
davepcallan / LINQBenchmarks.cs
Created February 12, 2025 12:30
.NET Framework 4.8 v .NET 9 LINQ benchmarks
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Linq;
namespace Benchmarks
@davepcallan
davepcallan / AverageBlogRankingBenchmark.cs
Created February 10, 2025 21:42
Benchmarking different ways of calculating average of a column in Entity Framework
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Microsoft.EntityFrameworkCore;
[MemoryDiagnoser]
[ReturnValueValidator]
public class AverageBlogRanking
{
[Params(1000)]
@davepcallan
davepcallan / EFQueryFlow.mmd
Created February 10, 2025 18:14
Entity Framework query flow sequence diagram
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davepcallan
davepcallan / GettingStartedWithBenchmarkDotNet.cs
Last active February 10, 2025 18:18
Simple string concat benchmark showing how to get started with BenchmarkDotNet and how to set some basic config
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using System.Text;
namespace Benchmarks;
[MemoryDiagnoser]