views:

69

answers:

1

I want to update a single field in my table for a particular row. I am using Entity Framework 4 and Visual Studio 2010.

Options I can think of are:

  • Using a Stored Procedure
  • Direct connection to the database and using sql statement

I am not aware of any more efficient method to perform this task.

[EDIT]
I would like to do the update in the same operation as the Get for that row, so that it is done in one DB call.

+1  A: 

No need to complicate things. Just change the one property and SaveChanges. Unless you're doing something odd, that should only change the one column. Look at the SQL to verify.

Craig Stuntz
Very good point, but how do I do it in the same operation as the Get call? I want to limit the DB call.
Picflight
This sounds like a premature optimization to me.
Craig Stuntz
"premature optimization," means to me that I should not worry about one call to DB right now, make it work and look at optimization at a later stage of development.
Picflight
Almost. It means optimize the slowest part of your app (I'm betting this is not it), not look later.
Craig Stuntz