summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Database/Tables/Place.cs
blob: 2914aa7e3f71dd64fa983cc1ac518f2dd105a381 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace WhatApi.Database.Tables;

public class Place : BaseAuditableEntity
{
    public Guid Id { get; set; }
    public Guid ContentId { get; set; }
    public Content Content { get; set; } = null!;
    public required Point Location { get; set; }
}

public class PlaceConfiguration : IEntityTypeConfiguration<Place>
{
    public void Configure(EntityTypeBuilder<Place> builder) {
        builder.ToTable("place");
        builder.HasKey(x => x.Id);
        builder.Property(x => x.Location).IsRequired();
        builder.HasOne(x => x.Content);
        builder.Property(x => x.Location).HasColumnType($"geometry(point,{Constants.Wgs84SpatialReferenceId})");
        builder.HasIndex(x => x.Location).HasMethod("gist");
    }
}