3
I need to do a routine that will set one flag in several records that meet some requirements, and would like to keep this in control of the Nhibernate.
However, I couldn’t find any way to do a mass update (update batch), with the compileable and repeatable resources of Fluentnhibernate (and Nhibernate), I wouldn’t want to leave for HQL, where I’ve realized it’s possible, but would lose all the advantages of refactoring.
What I would like to do is something very simple, similar to this in SQL:
UPDATE TABELAFLAGS SET COLUMNFLAG1 = 1 WHERE COLUMNFLAG2 = 2 AND COLUMNFLAG3 = 3
That would be so in HQL:
Session.CreateQuery(
@"update ClassFlags set flag1 = :p1 where flag2 = :p2 and flag3 = :p3"
).SetInt32("p1", 1).SetInt32("p2", 2).SetInt32("p3", 3).ExecuteUpdate();
It is possible to do this efficiently with Session.Update()
or some other method?
is C# with Fluentnhibernate ?
– user6026
Yes, Nhibernate is C#, in java is Hibernate. I will add the tag.
– Fernando Leal
Yeah, I just wanted to make sure it was with C# @Fernando
– user6026