Change column automatically EF

0

I have a field called Status: which can receive 3 values. How could the value of that field change depending on the condition of another field that is in my database? I am using entity framework 5 EF.

Let's imagine that I have the following model.

public class batches
(
  [Key]
  public int Id {get;set;}

  public DateTime Start {get;set;}

  public DateTime End {get;set;}

  public String Status {get;set;}
)

I would like to fill the Start field with the value of the status column change to In Process and when I fill the End field the Status column changes me to complete ect.

Thanks in advance.

    
asked by AlejandroMst 08.08.2018 в 14:44
source

1 answer

0

You could have the model evaluate the information in these fields and consequently return what you want as soon as you perform a GET to the Status field.

private string _status;
public string Status
{
    get
    {
        //CAMBIAR DECISION A LO QUE DESEAS EVALUAR
        if (true)
        {

            return _status = "In Process";
        }
        else
        {

            return _status = "complete";
        }
    }
    set
    {
        _status = value;
    }
}
    
answered by 08.08.2018 в 15:15