0
當我運行下面的代碼:DeleteOnSubmit:記錄不會被刪除,也不例外拋出
Public Function DeleteSessionItem(ByVal thisSessionItem As SessionItem) As Boolean
Using db As New SEMDBDataContext(My.Settings.SEMDBConnectionString)
db.DeferredLoadingEnabled = False
If thisSessionItem.Modified IsNot Nothing Then
db.Log = Console.Out
db.SessionItems.Attach(thisSessionItem, True)
db.SessionItems.DeleteOnSubmit(thisSessionItem)
Try
DeleteSessionItem = db.GetChangeSet.Deletes.Count > 0
db.SubmitChanges()
Catch ex As Exception
DeleteSessionItem = False
End Try
End If
End Using
End Function
沒有異常拋出,變更集刪除計數爲1和SQL語句是:
DELETE FROM [dbo].[SessionItems] WHERE ([ItemID] = @p0) AND ([Modified] = @p1)
-- @p0: Input BigInt (Size = 0; Prec = 0; Scale = 0) [61]
-- @p1: Input Timestamp (Size = 8; Prec = 0; Scale = 0) [SqlBinary(8)]
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.30729.1
SELECT NULL AS [EMPTY]
FROM [dbo].[SessionItems] AS [t0]
WHERE [t0].[ItemID] = @p0
-- @p0: Input BigInt (Size = 0; Prec = 0; Scale = 0) [61]
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.30729.1
但該記錄不會從SessionItems表中刪除。這是一個子表(表Sessions),而SessionItems沒有子表。
任何想法爲什麼記錄沒有被刪除?