using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace NejCommon.Models; [Owned] public class LocalizedString { [Column(TypeName = "jsonb")] public Dictionary Values { get; set; } = new(); public string this[Langauge locale] { get => Values.TryGetValue(locale, out var v) ? v : ""; set => Values[locale] = value; } public static implicit operator LocalizedString(string value) => new() { Values = new() { [Langauge.EN] = value } }; public static implicit operator LocalizedString(Dictionary value) => new() { Values = value }; public static implicit operator Dictionary(LocalizedString value) => value.Values; }