If you need a validation attribute on your input object that simply requires the user to tick a box to confirm something, you can use the following The class is then consumed like so This will work with any app that uses Data Annotations as a form of validation, such as ASP.NET MVC apps or …
Continue reading Click to confirm
Author:Peter Morris
Mocking Entity Framework Core DbSet
Entity Framework Core introduces various extensions to IQueryable to allow asynchronous operations.
It can be difficult to mock dependencies that use those extensions when writing tests.
This is how it’s done…
Tom Lehrer adds newly discovered elements to his song The Elements
After many decades of writing his famous song The Elements, I’ve inspired Tom Lehrer to add the newly discovered elements!
Entity Framework Core, SQL Server, and Deadlock victims
If you are seeing frequent deadlocks when inserting rows into a SQL Server table, here is the solution…
Generating globally unique mostly-sequential keys for DB rows across multiple processes
This article explains how you can generate GUID formatted values that are unique across processes and will also be appended to the end of SQL Server indexes.
Blazor: Scoping services to a component
Sometimes you need your component to have its own unique (isolated) dependency injection container, where all the injected services are disposed with the component.
This article explains how that can be done.
Blazor setTimeout
If you are familiar with setTimeout in JavaScript, here is how you do something similar in Blazor.
Blazor-Fluxor ranked #7 in top 10 Blazor tools!
I was really pleased to see my Blazor library “Fluxor” mentioned in this Visual Studio Magazine article!!!
Assigning a piped async result to a variable in an Angular view
If you have an Observable<x> in your component you might find yourself doing something like this {{ ( source$ | async)?.property1 }}{{ ( source$ | async)?.property2 }} This will subscribe to the source$ observable more than once. A commonly used technique to avoid this is to assign the result of the async into a view …
Continue reading Assigning a piped async result to a variable in an Angular view
Implementing a really simple Elvis Operator in TypeScript
Here is a simple routine that implements what is known as the Elvis Operator in TypeScript. In C# you can write code like thisNullable<int> age = person?.BestFriend?.Mother?.CurrentHusband?.Age); If any of the values along the way it will return a null rather than throwing a NullReferenceException. Using the class in my previous blog Get a Lambda expression …
Continue reading Implementing a really simple Elvis Operator in TypeScript