3
Answers

Store Sessions using C# and EF

Dave Bell

Dave Bell

1y
619
1

Hello, My Session Object looks like below -

public class Session
{
    public int Id { get; set; }
    public int StudentId { get; set; }
    public string? SessionDetails { get; set; }
    public DateTime StartTime  { get; set; }
    public DateTime EndTime { get; set; }
    public int Valid { get; set; }
}

I wish to create a POST that will create an instance of session with StartTime as systemdate  (EF:  Add). After session is over I would call the EF : Update call to store the EndTime.

Question: Is there any way to get the system generated Id in response when I Add the instance? That way I can keep the Id and then use it to Update.

Answers (3)