Update
In the Nhibernate 5.0 the following functionality has been included: Modifying entities Inside the database, that implements something similar to the one sought in this question: Updating entities, which would be the possibility of a similar implementation to that:
using NHibernate.Linq;
...
session.Query<Cat>()
.Where(c => c.BodyWeight > 20)
.UpdateBuilder()
.Set(c => c.BodyWeight, 20)
.Update();
Which would be equivalent to an SQL like:
UPDATE Cat
SET BodyWeight = 20
WHERE BodyWeight > 20;
I think I know the answer you want to read:
With LINQ something in that idea:
// Atenção isso não existe
(from entity in db.Registro update entity.Flag = 1 where entity.Id = 1).Apply();
Or with Lambda something similar to that:
// Atenção isso também não existe
db.Registro.Where(t => t.Id = 1).Update(t => t.Flag = 1);
But unfortunately I have some bad news for you:
These "yet" approaches do not exist, so I recommend that follow the answers already exist (the most complete in my opinion is the @Harrypotter)
I’ve also looked for an approach similar to yours with Nhibernate, here, and found that both Lambda and Linq, are geared to queries (Query s), and not to "data change routines";
Perhaps in the near future, LINQ, LAMBDA and Orms will be incorporated into something that allows this. But for now the answer is no, there is no way.
On SOEN, there are also posts talking about this, here, with good approaches.
Are you using some ORM?
– Fernando Leal
You can put the code that brings the selection of the object, please?
– Leonel Sanches da Silva
type: update table set meu_field = new_value, but only in lambda. Entity use 6
– pnet
Man, this is a lousy practice. What is the need for you to make a update manual using EF6?
– Leonel Sanches da Silva
@pnet analyze the answers and check if they answer your question?
– user6026
So Morrison, what I really seek are good practices. Your comment I liked, but I stumble on my limitations in the use and knowledge of EF.
– pnet