Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

61 total results found

NET Core Background Services

.NET

NOTE: Refer to this page for how to register and consume a background service: Consuming NET Core Background Service with DI General Lots of the ceremony of a background service has been wrapped up and tested, in this class: BackgroundService_Base NOTE: As ...

service
programming
dotnet
.net

Getting Correct Scheme, Host, Port Behind a Proxy

.NET

When running an API behind a reverse proxy, such as NGINX, the service will not, by default, see the scheme and port of the incoming call. By default, the API service will see the scheme and port of the direct call to it, which will likely be http and some int...

nginx
dotnet
.net
programming

How to Create IOptions Instance

.NET

It’s pretty standard for classes to require configuration in their constructors in the IOptions form.But, this doesn’t make testing very easy. Here’s a workaround for pushing an IOptions instance into a class constructor, that needs config. This example is f...

dotnet
.net
programming

IServiceProvider vs IServiceScopeFactory

.NET

References: Net Core DI Truths Internet’s Claim of Anti-Patterns Contrary to what the internet says about service locator usage as anti-pattern, there will always be the need for logic to dynamically access services from DI.This is because the NET Core runti...

DI
dotnet
programming
.net

Net Core DI Truths

.NET

References: NET Core DI Best Practices Here’s a list of behaviors of the NET Core DI registry: All dynamic access to services (from DI) are requested through a service provider.This is what people call a service locator. For example:var foosvc = _servic...

DI
dotnet
.net
programming

HowTo Access DI Services

.NET

NOTE: If you are looking for how to generate an instance of ServiceProvider, outside of NET Core runtime, like for a unit test, see this: Duplicating .NET Core DI Here’s a good reference on how DI scoping works: The dangers and gotchas of using scoped service...

DI
.net
.net
programming

HowTo Make .Net Desktop App DPI Aware

.NET

For a better desktop UI experience, it is necessary to have access to the current screen size and pixel density of the display (DPI), so that an application controls and text fonts can be adjusted as needed for good layout and presentation. Here is a list of ...

dotnet
programming
.net

Unit Tests with PostgreSQL Backends

.NET

In order to easily stand up a Postgres database for unit and integration testing, we need a class that can encapsulate the effort, to an easy call surface. Below we have a helper class that will manage the life-cycle of a test database, in PostgreSQL. Given ...

database
dotnet
testing
programming
.net
postgres

EF - Backend vs .NET Datatypes

.NET

Here's a list of what datatypes that Entity Framework uses to store .NET datatypes in a couple different database engines. .NET Datatype SQL Server PostgreSQL SQLite Comments bool bit boolean INTEGER byte tinyint smallint (Postgr...

programming
.net
dotnet
EF
EntityFramework
SQLite
postgres
database
SQL

Unit Testing Conventions

.NET

Suppress Async Warning Project-Wide Since we have several calls to base classes for diagnostics and such that are async, it's a good idea to standardize on all Test methods be async. The problem is that not every test method contains an awaited call. so, we ...

unittests
programming
testing
dotnet
.net

Base Domain Type

Object Management Stack

Here are notes about the base domain type, its usage, and design choices. NOTE: Some of these are restrictions of the C# compiler, that makes it necessary to include some boilerplate in domain objects. Design Requirements Here are design requirements for ou...

Dapper
database
EF
DDD
dotnet
.net
programming

Example Derived Type

Object Management Stack

Here's a working example of a domain type that derives from the base type in this page: Base Domain Type /// <summary> /// This is a sample domain type that uses our base type. /// It is only for testing. /// For this type to exist, it requ...

programming
database
Dapper
DDD
.net
dotnet

OGA.PostGres.Lib Usage

HowTo

Here’s notes on how to create and manage databases with OGA.PostGres.Lib. This applies to use cases for: Standing up a temporary database for unit and integration testing. Creating live database tables with compatible column types for storing class ...

programming
.net
postgres
dotnet

EF: Logging

.NET

Here's some notes on how we implement logging in EF. We've currently implemented it in our dynamic domain dbcontext, DynamicDbContext. To make it work, we just have to create an instance of DbContextLoggingConfig, and pass it to our top-level dbcontext const...

logging
dotnet
.net
programming

EF: Data Contexts - DbContexts

.NET

When working in EF, you will come across the need to create a DbContext type. MS has a base class that you inherit from, called: DbContext. It is useful to implement either a two or three layer DbContext. See this page for EF Logging implementation: EF: Log...

programming
dotnet
.net
EntityFramework
EF
database

Mocking a DBContext for Testing

.NET

The easiest means to mock a data context for testing, is to use an in-memory database. An in-memory database is known by its string-name within a process. Each data context accessing the database instance must use its name, via options. See this page for EF ...

dotnet
programming
.net
testing

HowTo Run DotNet Core App as Standalone

.NET

How to startup a net core application and specify the listening IP address and port: exename.exe run --urls "http://192.168.1.110:6000" Here's an alternate for starting a service that exists as a dll: dotnet OGA.HostControl.Service.dll --urls http://192.168...

.net
dotnet
deployment

VS Library - csproj Contents

.NET

Here are some standard things for the csproj file of a .NET library project. The top Property Group should list the following things: <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <PackageId>OGA.NugetRepoClient.Lib</PackageId> <P...

dotnet
.net
programming

.NET 5 Global Using Error

.NET

If you have a project that is targeting a .NET 5, and you see the following error, follow this page: The error indicates that your csproj file likely has a statement that only works in .NET6 (C# v10) and later. Open your csproj file and look for a statemen...

.net
programming
dotnet

Create Nuget for Multiple Targets or Architectures

.NET

Creating nuget packages that contain libraries for multiple frameworks or runtimes, requires some non-trivial effort.So, this page explains the steps required. Some of this was taken from here: Non-Trivial Multi-Targeting with .NET Project Setup For multipl...

nuget
programming
dotnet
.net