是否可以在SubSonic3中执行此类操作?
_db.Update<Product>()
.Set("UnitPrice")
.EqualTo(UnitPrice + 5)
.Where<Product>(x=>x.ProductID==5)
.Execute();
我需要这样的东西:
UPDATE Blocks
SET OrderId = OrderId - 1
WHERE ComponentId = 3
但是在SubSonic3中
答案 0 :(得分:1)
我认为你可以在这里展示如何使用亚音速3
// Linq To Sql可能没有看到的一件事是能够运行更新 //和插入,我一直都错过了,现在已经用SubSonic 3.0实现了:
db.Update<Products>().Set(
x => x.Discontinued == false,
x => x.ReorderLevel == 100)
.Where(x=>x.Category==5)
.Execute();
db.Insert.Into<Region>(x => x.RegionID, x => x.RegionDescription)
.Values(6, "Hawaii")
.Execute();
这里有一个link到完整演示
答案 1 :(得分:0)
我选择
var model = ClassName.SingleOrDefault(x => x.id == 1);
model.name = "new name";
model.tel = " new telephone;
model.save();
完成