Possible to update a row without pulling down and updating every column?
For examples sake, lets say I have a t开发者_Python百科able containing these columns
- ID (primary key, auto increment)
- FirstName (32 characters)
- LastName (32 characters)
- Picture (binary JPEG data containing on average 10k of data)
Using SubSonic and/or LINQ how can I update only the FirstName column of a record and not try to get the Picture column or try to update the picture column?
Right now the only way I see of doing it is something like this:
var p=Data.People(x=>x.ID==SomeID);
p.FirstName="Foobar";
p.Save();
What happens over the line from what I can tell though is that it completely loads the object and completely saves the object. I don't want to have to transfer over 10k of data for such a simple operation though. How do I fix this?
Here's an old example from Rob for a SubSonic 3 preview version.
db.Update<Products>().Set(
x => x.Discontinued == false,
x => x.ReorderLevel == 100)
.Where(x=>x.Category==5)
.Execute();
http://blog.wekeroad.com/2008/11/12/subsonic-3-0-preview-2
In your terms:
db.Update<People>().Set(
p => p.FirstName == "FooBar")
.Where(p => p.ID == SomeId)
.Execute();
精彩评论