The idea for the syntax comes from here: http://blogs.telerik.com/openaccessteam/posts/13-06-24/bulk-update-and-delete-as-easy-as-linq
...and while the naming is certainly debatable, I can't think of another way to do it, except possibly: session.Query<Animal>() .Where(x=>x.Age>3) .Set(y=>y.Name,"Peter") .Set(y=>y.Age,y=>y.Age+1) .Execute() The insert is a bit tricky too, since... session.Query<Animal>() .Where(x=>x.Age>3) .InsertInto(x=>new Human{ Name=x.Name, Age=x.Name+10 }) ..requires that Human can be constructed and initialized like that. It is currently possible to use it with a parameterized constructor, but the parameters are completely ignored, which may be confusing. /G 2014-12-19 1:28 GMT+01:00 Gunnar Liljas <gunnar.lil...@gmail.com>: > > Absolutely possible, but the (big) difference is that > > 1. An anonymous object will lose the static type relationship with what > you're updating/inserting, which kind of defeats the point of Linq bulk > operations. > 2. You will lose the possibility to express anything but simple value > expressions, i.e "SET FullName = FirstName + ' ' + LastName" ( > Set(x=>x.FullName,x=>x.FirstName + " " + x.LastName), will not be possible. > > /G > > 2014-12-19 1:20 GMT+01:00 Craig van Nieuwkerk <crai...@gmail.com>: >> >> Looks nice. But yes, I think if you can have anonymous object for the >> parameters this would be better. I have used FluentMigrator and it does >> this for Update/Insert pretty nicely. >> >> On Fri, Dec 19, 2014 at 11:13 AM, Alexander Zaytsev <haz...@gmail.com> >> wrote: >>> >>> Very nice. I would like to remove word "All" from the operations.Also >>> why do we need "Set" in update statement? >>> >>> On Fri, Dec 19, 2014 at 1:04 PM, Ricardo Peres <rjpe...@gmail.com> >>> wrote: >>>> >>>> Very nice! I implemented strongly typed delete in NH-3488 >>>> <https://nhibernate.jira.com/browse/NH-3488>, but the syntax was a bit >>>> different: >>>> >>>> session.Delete<Product>(x => x.Price > 100); >>>> >>>> Do you have a pull request waiting to be issued? >>>> >>>> RP >>>> >>>> >>>> On Thursday, December 18, 2014 11:21:06 PM UTC, Gunnar Liljas wrote: >>>>> >>>>> 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 nhibernate-development+unsubscr...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> >>> --- >>> 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 nhibernate-development+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> >> --- >> 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 nhibernate-development+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- --- 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 nhibernate-development+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.