Unit Testing in C# with xUnit: A Beginner’s Guide

xUnit C# unit test: Assert.Equal failing with Expected 0, Actual 7.99 because the shipping rule uses > instead of >=

The first xUnit test most C# developers write checks a condition with Assert.True. When it fails, the runner tells you almost nothing about why: Quick answer: the first rule of any xUnit C# tutorial is to compare values with Assert.Equal(expected, actual), so a failure prints both of them. Below, we build a small class library … Read more >>

Entity Framework Core Tutorial for Beginners (.NET 10 + SQL Server)

EF Core tutorial featured image: coffee cafe customers with their order counts and totals from a real EF Core 10 Include query

Say you roast coffee in Portland and sell wholesale to four cafes in Oregon, Colorado, Texas and Louisiana. You want their orders in SQL Server, and you’d rather not hand-write a single INSERT or JOIN. That’s what this EF Core tutorial builds: C# classes plus a DbContext describe the data, a migration creates the tables, … Read more >>

LINQ GroupBy in C#: Group, Count and Sum a List

LINQ GroupBy in C#: sales grouped by state with a count and a dollar total per group, TX 3 sales $3,400, CA $2,650, NY $2,000

For a C# LINQ group by, call GroupBy with a key selector such as s => s.State. You get one group per key, and each group carries its Key plus its items, so Count() and Sum() work per group: Below, the same eight US sales get grouped by two columns, filtered like SQL HAVING, turned … Read more >>

Nullable Reference Types in C#: Enable Them and Fix the Warnings

C# nullable reference types: a public string Name field raising warning CS8618, fixed by declaring it required string Name

The most common mistake when a team turns on C# nullable reference types is silencing every warning with the ! operator. The build goes quiet, but the app still crashes, because ! only hides the warning: Quick answer: keep <Nullable>enable</Nullable> on, mark values that can be missing as string?, and fix each warning with a … Read more >>

Blazor Components and Parameters (with Examples) in .NET 10

Blazor components featured card: a ProductCard child sends 2 x Two-Person Tent through EventCallback to the parent order list, Subtotal: $477.94 (4 items)

Say you run the web store for a Portland outdoor gear shop. The product page repeats the same card markup for six items, and every price fix means editing six copies. Blazor components fix that: you write the card once as a .razor file, pass each product in with [Parameter] properties, and send clicks back … Read more >>

Blazor QuickGrid Tutorial: Sorting, Filtering and Paging (.NET 10)

Blazor QuickGrid featured card: an orders grid sorted by Total descending with $2,416.01 on top and the Paginator text 200 items Page 1 of 20

Say the sales manager at a Dallas furniture store wants this year’s 200 orders on one screen, sorted by total, searchable by customer and ten rows a page. In Web Forms you’d drag in a GridView. Blazor doesn’t have one. The built-in answer is Blazor QuickGrid, Microsoft’s free grid component. Give it an IQueryable, mark … Read more >>