From 526c2364b9ad685d1c000fc8a168bf1305aaa8b7 Mon Sep 17 00:00:00 2001 From: vman Date: Fri, 18 Nov 2022 16:08:51 -0500 Subject: Add project files. --- .../Model/RouteStore.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 VNLib.Plugins.Essentials.Content.Routing/Model/RouteStore.cs (limited to 'VNLib.Plugins.Essentials.Content.Routing/Model/RouteStore.cs') diff --git a/VNLib.Plugins.Essentials.Content.Routing/Model/RouteStore.cs b/VNLib.Plugins.Essentials.Content.Routing/Model/RouteStore.cs new file mode 100644 index 0000000..8650f30 --- /dev/null +++ b/VNLib.Plugins.Essentials.Content.Routing/Model/RouteStore.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; + +using Microsoft.EntityFrameworkCore; + +using VNLib.Plugins.Extensions.Data; + +namespace VNLib.Plugins.Essentials.Content.Routing.Model +{ + internal class RouteStore : DbStore + { + private readonly DbContextOptions Options; + + public RouteStore(DbContextOptions options) + { + Options = options; + } + + public override string RecordIdBuilder => Guid.NewGuid().ToString("N"); + + protected override IQueryable GetCollectionQueryBuilder(TransactionalDbContext context, params string[] constraints) + { + string hostname = constraints[0]; + return from route in context.Set() + where route.Hostname == hostname + select route; + } + + protected override IQueryable GetSingleQueryBuilder(TransactionalDbContext context, params string[] constraints) + { + string id = constraints[0]; + return from route in context.Set() + where route.Id == id + select route; + } + + public override TransactionalDbContext NewContext() => new RoutingContext(Options); + + protected override void OnRecordUpdate(Route newRecord, Route currentRecord) + { + throw new NotImplementedException(); + } + } +} -- cgit