How can I make NHibernate produce this t-sql request ?
Update top (n) Tasks set MODIFICATIONS where CONDITION
I don\'t want to do a Transaction + batch update.<
Please, check this:
a cited code snippet:
ISession session = sessionFactory.OpenSession();
ITransaction tx = session.BeginTransaction();
string hqlVersionedUpdate = "update versioned Customer set name = :newName where name = :oldName";
int updatedEntities = s.CreateQuery( hqlUpdate )
.SetString( "newName", newName )
.SetString( "oldName", oldName )
.ExecuteUpdate();
tx.Commit();
session.Close();
So, this way, we can defin UPDATE with HQL (using our domain model) and executing the udpate directly at once on DB side
NOTE: for more details also check this blog post: NHibernate – Executable DML by Ayende