我已经很多年没有写过 SQL 了,现在我正在开发一个更“渴望性能”的网站。有人可以帮我将其转换为删除 SQL 命令吗?
我有一堆这样的,所以帮助我解决这个问题对我来说很重要,谢谢!
我做到了这一点:
Delete FROM [DbName].[dbo].[RatingListTriangleModels]
WHERE ...
Linq 选择命令:
var allRatingListObjects = from row in ctx.RatingListTriangle
where
(row.To1Id == myToid && row.To2Id == theirTradeObjectid)
|| (row.To2Id == myToid && row.To3Id == theirTradeObjectid)
|| (row.To3Id == myToid && row.To1Id == theirTradeObjectid)
select row;
更新:这是我寻求的工作解决方案:
using (SqlCommand command = new SqlCommand
("delete TBL from RatingListTriangleModels TBL where ( TBL.To1Id = @MY_ID and TBL.To2Id = @OTHER_ID ) or ( TBL.To2Id = @My_ID and TBL.To3Id = @OTHER_ID ) or ( TBL.To3Id = @My_ID and TBL.To1Id = @OTHER_ID )", cn))
{
// Add new SqlParameter to the command.
command.Parameters.Add(new SqlParameter("MY_ID", myToid));
command.Parameters.Add(new SqlParameter("OTHER_ID", theirTradeObjectid));
var no = command.ExecuteNonQuery();
}