我正在尝试实现以下代码,但我不断收到以下错误。
ObjectStateManager中已存在具有相同键的对象。现有对象处于Unchanged状态。如果对象处于添加状态,则只能再次添加到ObjectStateManager。
Function Create(lkmeasure As LkMeasure, ByVal oForm As FormCollection) As ActionResult
Dim ObjectiveList As New List(Of String)
Try
If ModelState.IsValid Then
If Not DirectCast(Session("LoggedInUser"), SecurityUser).SecurityRole.RoleName.ToLower.Equals(cCommon.UserRole.Administrator.ToString.ToLower()) Then
lkmeasure.AgencyID = DirectCast(Session("LoggedInUser"), SecurityUser).AgencyID
End If
lkmeasure.StatusID = Convert.ToInt16(oForm("MeasureStatus").ToString())
If Not oForm("PerformanceObjectives") Is Nothing AndAlso oForm("PerformanceObjectives").Length > 0 Then
'If Convert.ToInt16(oForm("PerformanceObjectives").ToString()).Equals(0) Then
' lkmeasure.ObjectiveID = 0
'Else
'lkmeasure.ObjectiveID = Convert.ToInt16(oForm("PerformanceObjectives").ToString())
ObjectiveList = oForm("PerformanceObjectives").ToString().Split(",").ToList()
'End If
End If
lkmeasure.MeasureCreateDate = DateTime.Now
lkmeasure.MeasureUpdateDate = DateTime.Now
'Dim lkMeasureObjList As New List(Of LkMeasure)
For Each obj In ObjectiveList
Dim lkmeasureobj As New LkMeasure
lkmeasureobj = lkmeasure
lkmeasureobj.MeasureCreateDate = DateTime.Now
lkmeasureobj.MeasureUpdateDate = DateTime.Now
lkmeasureobj.ObjectiveID = Convert.ToInt16(obj)
db.LkMeasures.AddObject(lkmeasureobj)
db.SaveChanges()
lkmeasureobj = Nothing
Next
Return RedirectToAction("Index")
End If
Call CreateViewBag()
Return View(lkmeasure)
Catch ex As Exception
Return Nothing
End Try
End Function
我已经使对象没有任何东西,但它仍然表示添加了对象。
答案 0 :(得分:0)
如果您想为GetFitARpMLE(z,4)
中的每个值添加新的> GetFitARpMLE(z,4)
$loglikelihood
[1] -2350.516
$phiHat
ar1 ar2 ar3 ar4
0.0000000 0.0000000 0.0000000 -0.9262513
$constantTerm
[1] 0.05388392
,请尝试以下内容:
LkMeasure