我在 SQL 中有 2 个表,它们都有一个名为 Selection_ID 的字段。我想Selection_ID = inpSelectionID
使用 Linq-to-SQL 删除所有行。
我的桌子:
我的 C# 函数:
void buttonDeleteSelectionList_Click(object sender, RoutedEventArgs e, Canvas canvasAdvancedSearchFieldResults, int inpSelectionID)
{
PositionServiceReference.PositionServiceClient service = new PositionServiceReference.PositionServiceClient();
service.DeleteSelectionCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(service_DeleteSelectionCompleted);
service.DeleteSelectionAsync(inpSelectionID);
}
我的服务代码 PositionService.svc.cs:
[OperationContract]
void DeleteSelection(int inpSelectionID)
{
PositionDataClassesDataContext context = new PositionDataClassesDataContext();
context.Lloyds_Selection.DeleteOnSubmit(inpSelectionID);
context.SubmitChanges();
context.Lloyds_Selection_Vessels.DeleteOnSubmit(inpSelectionID);
context.SubmitChanges();
}