「IncidentActions」テーブルに新しいデータを追加し、同時に「Incident」テーブルの 3 つの列を更新する保存ボタンがあります。
どうすればこれを行うことができますか
これは、これを達成するために使用しているC#コードです。
protected void cmdSave_Click(object sender, EventArgs e)
    {
        Context db = new Context();
        // This will check the Action from the actions table and 
        var actionID = (from i in db.Actions
                       where i.Actions == tbActionType.Text
                       select i.ActionsID).First();
        long ID = Convert.ToInt64(Request.QueryString["IncidentID"]);
        // TODO: update the incident table accordingly
        IncidentAction act = new IncidentAction
        {
            IncidentID = ID,
            ActionDate = (DateTime)dpActionDate.SelectedDate,
            ActionsID = Convert.ToInt32(actionID),
            StatusID = statID,
            IsPublic = false,
            Title = tbTitle.Text.Trim(),
            PeriodValue = Convert.ToInt64(txtDuration.Text),
            Description = txtDescription.Text.Trim(),
            EstimatedCost = txtEstimatedCost.Text == string.Empty ? (decimal?)null : Convert.ToDecimal(txtEstimatedCost.Text),
            ActualCost = txtActualCost.Text == string.Empty ? (decimal?)null : Convert.ToDecimal(txtActualCost.Text),
            LastUpdated = DateTime.Now,
            UpdatedBy = Convert.ToString(loggedInUserName),
            CreatedByUserID = Convert.ToInt32(loggedInUserID),
            Active = true
        };
                db.IncidentActions.Add(act);
                db.SaveChanges();
                Incident inc = new Incident
                {
                    IncidentID = ID,
                    StatusID = statID_new,
                    IncidentPendingDate = DateTime.Now
                };
                db.SaveChanges();
            }
    }