如何使用SilverLights Linq-to-SQL从数据库中删除一行

时间:2013-03-14 15:11:38

标签: c# silverlight 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();
}

表:

enter image description here

1 个答案:

答案 0 :(得分:1)

你的LINQ Where函数不应该读:     .Where(l => l.Selection_ID == inpSelectionID&& l.ImoNumber == inpImoNumber) 代替?