I'm having a routine that will set a flag in several records that meet certain requirements, and I'd like to keep that in control of NHibernate .
However, I have not found any way to do a bulk update (update batch), with the FluentNHibernate compileable and refactorable NHibernate I would not want to go to HQL , where I already realized that it is possible, but I 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
What would be like this 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();
Is it possible to do this efficiently with Session.Update()
or some other method?