开发者

SubSonic3 Update Question

开发者 https://www.devze.com 2022-12-20 09:39 出处:网络
Is it possible to do something like this in SubSonic3? _db.Update<Product>() .Set(\"UnitPrice\") .EqualTo(UnitPrice + 5)

Is it possible to do something like this in SubSonic3?

_db.Update<Product>()
    .Set("UnitPrice")
    .EqualTo(UnitPrice + 5)
    .Where<Product>(x=>x.ProductID==5)
    .Execute();

I would need something lik this:

UPDATE      Blocks
SET         OrderId = OrderId - 1
WHERE      开发者_如何转开发 ComponentId = 3

But in SubSonic3


I think you can here is a sample for demonstrating how you can use subsonic 3

// One thing you might not have seen with Linq To Sql is the ability to run Updates //and Inserts, which I've always missed and have now implemented with 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();

and here a link to the full demonstration


i do it as a select

var model = ClassName.SingleOrDefault(x => x.id == 1);

model.name = "new name";
model.tel = " new telephone;

model.save();

done

0

精彩评论

暂无评论...
验证码 换一张
取 消