.NET code examples

Stripe .NET checkout example to add online payments

Stripe .NET checkout example to add online payments

Download an ASP.NET Core Stripe checkout example that uses the Stripe.net NuGet package to take online payments through a Web API endpoint.
xUnit project example for unit testing in .NET and C#

xUnit project example for unit testing in .NET and C#

Download an xUnit test project to help you unit test your C# code in a .NET project. It includes Fact and Theory examples alongside different Assert methods.
Using Moq in an xUnit project to unit test a .NET project

Using Moq in an xUnit project to unit test a .NET project

Download an xUnit and a .NET class library project that uses the Moq mocking framework to mock objects as part of unit tests.
Get started with Entity Framework Core

Get started with Entity Framework Core

Get started with EF Core includes creating a DbContext, adding a migration, CRUD operations, the Include method, raw SQL queries and stored procedures.
ASP.NET Core Web API CRUD methods example

ASP.NET Core Web API CRUD methods example

Download an ASP.NET Core Web API code example which includes endpoints for each of the CRUD methods (Create, Read, Update and Delete).
Data annotation .NET 8 additions in an Web API example

Data annotation .NET 8 additions in an Web API example

An ASP.NET Core Web API code example which includes the new data annotations for .NET 8 such as AllowedValues and Length.
TimeProvider example for mocking time and timer in xUnit

TimeProvider example for mocking time and timer in xUnit

A .NET 8 xUnit project which uses the TimeProvider and FakeTimeProvider class to mock time and a timer in unit tests.
Keyed services for ASP.NET Core dependency injection example

Keyed services for ASP.NET Core dependency injection example

Download the code example for injecting keyed services with dependency injection with an ASP.NET Core web app.
Azure DevOps pipeline example .NET project for CI/CD

Azure DevOps pipeline example .NET project for CI/CD

A .NET project for use in the CI/CD setup of a Azure DevOps pipeline. This demo can be used for a build and release pipeline.
FromQuery and other ASP.NET Core Web API attributes

FromQuery and other ASP.NET Core Web API attributes

An ASP.NET Core code sample that features examples of FromQuery, FromHeader, FromForm, FromRoute, FromServices and FromBody in a Web API.