简体   繁体   English

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

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

I have a SQL table and I want to use SilverLight Linq-to-SQL to delete a row. 我有一个SQL表,我想使用SilverLight Linq-to-SQL删除一行。 I am new to Linq-to-SQL, but the SQL statement should be 我是Linq-to-SQL的新手,但SQL语句应为

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

What is the Linq-to-SQL statement? 什么是Linq-to-SQL语句? This is my code: 这是我的代码:

[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();
}

Table: 表:

在此处输入图片说明

您的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