Update model database schema
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("contract"), PrimaryKey("VNr")]
|
||||
@ -12,19 +11,35 @@ namespace Elwig.Models {
|
||||
[Column("mgnr")]
|
||||
public int MgNr { get; set; }
|
||||
|
||||
[Column("date")]
|
||||
public string? DateString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly? Date {
|
||||
get {
|
||||
return DateString != null ? DateOnly.ParseExact(DateString, "yyyy-MM-dd") : null;
|
||||
}
|
||||
set {
|
||||
DateString = value?.ToString("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
|
||||
[Column("year_from")]
|
||||
public int YearFrom { get; set; }
|
||||
|
||||
[Column("year_to")]
|
||||
public int? YearTo { get; set; }
|
||||
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; }
|
||||
|
||||
[InverseProperty("Contract")]
|
||||
public virtual ISet<AreaCommitment> AreaCommitments { get; private set; }
|
||||
public virtual AreaCom? AreaCom { get; private set; }
|
||||
|
||||
[NotMapped]
|
||||
public int Area => AreaCommitments.Select(a => a.Area).Sum();
|
||||
public int? Area => AreaCom?.Area;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user