How to update data in a database object from a list (Entity Framework)

Viewed 86

I update data in the database. When expanding the Books list, you have to constantly edit the code (SomeValue1, SomeValue2, SomeValue3, etc.) Is it possible to immediately pass an object from the list to the found line?

using (var db = new MyContextDB())
{
    var result = db.Books.SingleOrDefault(b => b.BookNumber == bookNumber);

    if (result != null)
    {
        result.SomeValue = "Some new value";
        db.SaveChanges();
    }
}
0 Answers
Related