lee-r
2/27/2020 - 11:37 PM

EntityFramework ForeignKey via Id snippet From dropdown combobox parse

EntityFramework ForeignKey via Id snippet From dropdown combobox parse

public virtual Staff AssignedTo { get; set; }

    [ForeignKey("AssignedTo")]
    public int AssignedToId { get; set; }

    public void SetAssignedTo(string id)
    {
        if (int.TryParse(id, out int i)) AssignedToId = i;
    }