Templaty.Postgres
1.0.1
dotnet add package Templaty.Postgres --version 1.0.1
NuGet\Install-Package Templaty.Postgres -Version 1.0.1
<PackageReference Include="Templaty.Postgres" Version="1.0.1" />
<PackageVersion Include="Templaty.Postgres" Version="1.0.1" />
<PackageReference Include="Templaty.Postgres" />
paket add Templaty.Postgres --version 1.0.1
#r "nuget: Templaty.Postgres, 1.0.1"
#:package Templaty.Postgres@1.0.1
#addin nuget:?package=Templaty.Postgres&version=1.0.1
#tool nuget:?package=Templaty.Postgres&version=1.0.1
Templaty - PostgreSQL store
1. Introduction
Templaty - Postgres store - is a store based on PostgreSQL DB providing developers easy way to store their content into Postgres DB.
1.1 Use cases
- Template content should be stored into PostgreSQL DB;
- Template content may change over time in live time;
2. Quick start
To use
Templaty.Postgresyou have to enableTemplatyas well.
First of all, you need to import Templaty.Postgres as package;
dotnet add package Templaty.Postgres
2.1 ASP.NET with EF Core
To use Templaty.Postgres into ASP.NET projects just using into Startup or Program:
builder.Services.UseTemplaty(configator => configator.AddResourceStoreAssembly(typeof(Program).Assembly));
builder.Services.AddTemplatyPostgresStore<YourDbContext>();
Templaty.Postgres requires EF Core library to use Postgres as store.
Therefore you need to add ContentConfiguration into your DbContext or write it by your self.
public sealed class YourDbContext : DbContext
{
//..
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfiguration(new ContentConfiguration());
// ...
}
// ...
}
After database will be updated you will be able to use Postgres as the store.
2.2 Make your own template
Let's look at an example into project Templaty.Templaty.PostgresStoreSample (see Samples).
- Create template content and put it into table
contents;
Date: {{date}}
Temperature: {{temperature}} °C
Summary: {{summary}}
- Create a model with data
WheaterDistributionTemplate;
[Template.Source("Notifications_WheaterDistributionTemplate", Template.StoreType.Postgres)]
internal sealed record WheaterDistributionTemplate(DateOnly Date, int Temperature, string? Summary) : ITemplate;
- Use
ITemplateBuilderto get end-message from template;
var template = new WheaterDistributionTemplate(
DateOnly.FromDateTime(DateTime.Now.AddDays(2)),
Random.Shared.Next(-20, 55),
Summaries[Random.Shared.Next(Summaries.Length)]
);
var result = await _templateBuilder.LoadAndBuild(template);
Result will be something like that:
Date: 16.03.2025
Temperature: 8 °C
Summary: Balmy
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.18)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.11)
- Templaty (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 265 | 7/14/2025 |