Skip to content

Instantly share code, notes, and snippets.

Created November 8, 2023 19:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dcomartin/3c38566eda1da789c4f1499b706accbf to your computer and use it in GitHub Desktop.
using BenchmarkDotNet.Attributes;
using Microsoft.EntityFrameworkCore;
namespace FirstSingle;
public class BenchmarkDb
private readonly TestDbContext _db;
private readonly int _orderId;
public BenchmarkDb()
_db = new TestDbContext();
var rnd = new Random();
_orderId = rnd.Next(1, 1_000_000);
public async Task Single() => await _db.Orders.SingleAsync(x => x.OrderId == _orderId);
public async Task First() => await _db.Orders.FirstAsync(x => x.OrderId == _orderId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment