In LinqToSql, it is lovely easy to load a row, change a column, and submit the changes to the database:
using (MyDataContext wdc = new MyDataContext())
{
Article article = wdc.Article.First(p => p.ID == id);
article.ItemsInStock = itemsinstock;
wdc.SubmitChanges();
}
The only drawback: Article is huge. To load the entire article, just to update one column is way overkill and slows down my app significantly.
Is there a way to update a single column using LINQ, without having to load the entire row?
Right now I revert to using ExecuteCommand where speed is of essence, but this is ugly and error prone:
wdc.ExecuteCommand("UPDATE Article SET ItemsInStock = @1 WHERE ID = @2", itemsinstock,id);