using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WGneu.Models
{
    [Table("AT_plz"), PrimaryKey("Plz", "Okz"), Index("Id", IsUnique = true)]
    public class AT_Plz
    {
        [Column("plz")]
        public int Plz { get; set; }

        [Column("okz")]
        public int Okz { get; set; }

        [Column("country")]
        public string CountryCode { get; }

        [Column("id")]
        public string Id { get; }

        [Column("dest")]
        public string Dest { get; set; }

        [ForeignKey("Okz")]
        public virtual AT_Ort Ort { get; set; }

        [ForeignKey("CountryCode")]
        public virtual Country Country { get; set; }

        public ISet<AT_Plz> Orte(WgContext ctx)
        {
            return ctx.Postleitzahlen.Where(p => p.Plz == Plz).ToHashSet();
        }
   }
}