簡體   English   中英

如何使用SilverLights Linq-to-SQL從數據庫中刪除一行

[英]How to delete one row from database using SilverLights Linq-to-SQL

我有一個SQL表,我想使用SilverLight Linq-to-SQL刪除一行。 我是Linq-to-SQL的新手,但SQL語句應為

DELETE FROM Lloyds_Selection_Vessel WHERE Selection_ID == inpSelectionID AND ImoNumber == inpImoNumber

什么是Linq-to-SQL語句? 這是我的代碼:

[OperationContract]
void DeleteSelectionVesselRow(int inpSelectionID, int inpImoNumber)
{
    PositionDataClassesDataContext context = new PositionDataClassesDataContext();

    context.Lloyds_Selection_Vessels.DeleteAllOnSubmit(context.Lloyds_Selection_Vessels.Where(l => l.Selection_ID == inpSelectionID && x => x.ImoNumber == inpImoNumber));
    context.SubmitChanges();
}

表:

在此處輸入圖片說明

您的LINQ Where函數不應讀取:.Where(l => l.Selection_ID == inpSelectionID && l.ImoNumber == inpImoNumber)嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM