【发布时间】:2015-07-17 10:15:03
【问题描述】:
我正在使用DeleteAllOnSubmit 从表中删除行,如下所示:-
Try
Using ts As TransactionScope = New TransactionScope
Dim db As MyDataContext = New MyDataContext
db.my_tables.DeleteAllOnSubmit(From a In db.my_tables
Where a.col1 = given_col1 AndAlso
a.col2 = given_col2 AndAlso
a.col3 = given_col3)
db.SubmitChanges
End Using
Catch ex As Exception
' Log an exception if it occurs
End Try
但是当我这样做时,不会删除任何行。我通过在 DeleteAllOnSubmit 之前列出行来检查选择标准是否正确,因此:-
Dim rows_to_go As List(Of my_table) = (From a In db.my_tables
Where a.col1 = given_col1 AndAlso
a.col2 = given_col2 AndAlso
a.col3 = given_col3)).ToList
并在调试中检查rows_to_go 的内容,这表明某些行是按条件选择的,但使用 SQL Server Management Studio 检查表会显示前后相同的行。不抛出异常。
有谁知道为什么这个电话如此无效,我应该怎么做?
【问题讨论】:
标签: sql-server vb.net linq-to-sql