One Minute Knowledge: Is ToArrayAsync or ToListAsync faster for Entity Framework?
Short question, and a short answer: ToListAsync - but why?
Hey, I'm Steven a .NET Developer in Switzerland. I am a Microsoft MVP. Also, this blog is open source on GitHub.
Short question, and a short answer: ToListAsync - but why?
I saw mutliple places where people use GitHub runners to do some benchmarking. That can be a tricky thing to do.
New helper will be available with .NET 11: MediaTypeMap.GetMediaType and MediaTypeMap.GetExtension which makes the web-development a bit easier!
.NET 9 introduced Guid.CreateVersion7() / Guid.CreateVersion7(DateTimeOffset) methods to create sortable UUIDs / GUIDs based on the time of their creation. This can be particularly useful in databases where you want to maintain a chronological order of records (plus some perf benefits).
Currently, there is no native way to configure Entity Framework to use these methods when generating new GUIDs for primary keys. But we can do this on our own.
If you are using API Tests with the WebApplicationFactory you might did something like this to have a public Program class:
public partial class Program;
No more!
In xUnit v2 ITraceOutputHelper was needed (and injected) to make the console output inside your production code visible inside a test - in v3 it is easier: CaptureConsoleAttribute
Many benchmarks that are using ArrayPool, or more specificly ArryPool<T>.Shared, are not actually measuring a "real" scenarion or the benchmark is flawed in some way. Let's examine a bit on what is going on.
You need some advice around Random? Sure there is something on LinkedIn for that. Let's have a look.
In this - somewhat technical and barely usable - blog post, we will have a look at inlining and structs in C#. And how they can optimize performance in some interesting ways.
This is a very small blog post on why you should use CancellationTokens in your API.