So, now I have completed and old abandoned NH project, to create a Linq
implementation of the bulk functionality. It's complete in the sense that
all the unit tests from the HQL implementation passes with the Linq
implementation as well, plus a couple more. Before I clean things up, I'd
like you input on the syntax.
Currently it works like this:
Delete
session.Query<Animal>()
.Where(x=>x.Age>3)
.DeleteAll();
//all methods returns int (affected rows)
Update
session.Query<Animal>()
.Where(x=>x.Age>3)
.UpdateAll(x=>x
.Set(y=>y.Name,"Peter")
.Set(y=>y.Age,y=>y.Age+1)
)
Insert (i.e INSERT SELECT)
session.Query<Animal>()
.Where(x=>x.Age>3)
.InsertInto(x=>new Human{
Name=x.Name,
Age=x.Name+10
})
The Delete method was first implemented as
session.Delete<Animal>(x=>x.Age>3), but I added the IQueryable<T>.DeleteAll
extension for consistency.
I welcome any ideas on how this can be improved/changed.
/G
--
---
You received this message because you are subscribed to the Google Groups
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.