Skip to content

Commit 9f27f21

Browse files
committed
Internal Sytem db mapping
1 parent fccfc4a commit 9f27f21

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/ServiceMappings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace LearningHub.Nhs.OpenApi.Repositories.EntityFramework
88
using LearningHub.Nhs.OpenApi.Repositories.Map.Content;
99
using LearningHub.Nhs.OpenApi.Repositories.Map.External;
1010
using LearningHub.Nhs.OpenApi.Repositories.Map.Hierarchy;
11+
using LearningHub.Nhs.OpenApi.Repositories.Map.Maintenance;
1112
using LearningHub.Nhs.OpenApi.Repositories.Map.Messaging;
1213
using LearningHub.Nhs.OpenApi.Repositories.Map.Resources;
1314
using Microsoft.EntityFrameworkCore;
@@ -170,6 +171,7 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon
170171
services.AddSingleton<IEntityTypeMap, RoadmapMap>();
171172
services.AddSingleton<IEntityTypeMap, RoadmapTypeMap>();
172173
services.AddSingleton<IEntityTypeMap, EventMap>();
174+
services.AddSingleton<IEntityTypeMap, InternalSystemMap>();
173175
services.AddSingleton<IEntityTypeMap, ExternalSystemMap>();
174176
services.AddSingleton<IEntityTypeMap, ExternalSystemDeepLinkMap>();
175177
services.AddSingleton<IEntityTypeMap, ExternalSystemUserMap>();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace LearningHub.Nhs.OpenApi.Repositories.Map.Maintenance
2+
{
3+
using LearningHub.Nhs.Models.Entities.Maintenance;
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
6+
7+
/// <summary>
8+
/// Defines the <see cref="InternalSystemMap" />.
9+
/// </summary>
10+
public class InternalSystemMap : BaseEntityMap<InternalSystem>
11+
{
12+
/// <summary>
13+
/// The InternalMap.
14+
/// </summary>
15+
/// <param name="entity">The entity<see cref="EntityTypeBuilder{InternalSystem}"/>.</param>
16+
protected override void InternalMap(EntityTypeBuilder<InternalSystem> entity)
17+
{
18+
entity.ToTable("InternalSystem", "maintenance");
19+
20+
entity.HasIndex(e => e.Name)
21+
.IsUnique();
22+
23+
entity.Property(e => e.Name)
24+
.IsRequired()
25+
.HasMaxLength(50);
26+
27+
entity.Property(e => e.Description)
28+
.IsRequired()
29+
.HasMaxLength(2000);
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)