我正在使用 linq 从数据库中删除数据。我google了一下,查询了一下。我正在使用以下查询。
当我将调试器放在上面时,它没有显示任何错误。它进展顺利。但是当我检查我的数据库时,记录不会被删除。
同时做insert操作:
splitTradeDataContext db = new splitTradeDataContext();
tradeFile tlbTradeFile = new tradeFile();
tlbTradeFile.TradeNo = TradeNo + "_A";
tlbTradeFile.Status = Status;
tlbTradeFile.Scrip_Code = Scrip_Code;
tlbTradeFile.Inst_Type = Inst_Type;
tlbTradeFile.Expirydate = Expirydate;
tlbTradeFile.Strike_price = Strike_price;
tlbTradeFile.Option_type = Option_type;
tlbTradeFile.Sec_Name = Sec_Name;
tlbTradeFile.BookType = BookType;
tlbTradeFile.BookTypeName = BookTypeName;
tlbTradeFile.TerminalId = TerminalId;
tlbTradeFile.Branch_Id = Branch_Id;
tlbTradeFile.Buy_Sell = Buy_Sell;
tlbTradeFile.Trade_Qty = Trade_Qty;
tlbTradeFile.Market_Rate = Market_Rate;
tlbTradeFile.Pro_cli = Pro_cli;
tlbTradeFile.Party_Code = Party_Code + "_A";
tlbTradeFile.ParticipantCode = ParticipantCode;
tlbTradeFile.O_C_Flag = O_C_Flag;
tlbTradeFile.Sauda_Date = Sauda_Date;
tlbTradeFile.TradeModified = TradeModified;
tlbTradeFile.OrderNo = OrderNo;
tlbTradeFile.Opp_Broker_Id = Opp_Broker_Id;
tlbTradeFile.OrderTime = OrderTime;
tlbTradeFile.UnknowkNum = UnknowkNum;
var remove = from aremove in db.tradeFiles
where aremove.ID==int.Parse(gvTradeFile.SelectedRows[0].Cells[0].Value.ToString())
select aremove;
if(remove!=null)
db.tradeFiles.DeleteAllOnSubmit(remove);
有什么问题?我使用了错误的查询吗?或者我还剩下什么东西?