Linq And Query Batching or Future

53 views
Skip to first unread message

Sal

unread,
Aug 27, 2010, 12:17:14 PM8/27/10
to nhusers
Hi Guys,

Is there some way to use Future or other query batching with Linq and
NH? I have a linq query (for paging) that gets the total number of
records, as well as a list of entities and I'd like to issue the query
in one call. This is easy with criteria and future, but how about
Linq?

Sal

unread,
Aug 27, 2010, 4:42:17 PM8/27/10
to nhusers
OK, Let me try a different approach. This page here:
http://rndnext.blogspot.com/2009/05/using-nhibernate-multicriteria-and-linq.html
explains how to use the NHibernateQueryTranslator to convert a linq
query to criteria. Problem is, looking at NH 3, I do not see the
NHibernateQueryTranslator class. I'm guessing this was completely re-
written.

So, the question becomes, rather than have dependency on the old Linq
provider and NHibernateQueryTranslator , how can I use the new NH 3
Linq classes to translate a query to criteria? Basically, the end goal
is to be able to add support for multi-criteria, or even better the
use of Future<T>.

Thanks.

taber loveless

unread,
Aug 27, 2010, 5:43:33 PM8/27/10
to nhusers
I too am working on this exact issue... I hope someone can help us
out!

On Aug 27, 2:42 pm, Sal <salbass...@hotmail.com> wrote:
> OK, Let me try a different approach. This page here:http://rndnext.blogspot.com/2009/05/using-nhibernate-multicriteria-an...

Sal

unread,
Aug 27, 2010, 8:37:18 PM8/27/10
to nhusers
Yes, hopefully someone familiar with the new NH 3 Linq provider can
point us in the right direction. This seems like an issue many people
will come across.

Frans Bouma

unread,
Aug 28, 2010, 3:57:55 AM8/28/10
to nhu...@googlegroups.com
In v3, the linq provider is transforming to an AST for the hql pipeline, not
to criteria as the v2 one did. So that means it doesn't really is possible
to 'get' the criteria executed, as there's no set of criteria objects
created.

FB

> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to
> nhusers+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.

Mohamed Meligy

unread,
Aug 28, 2010, 4:51:26 AM8/28/10
to nhu...@googlegroups.com
I'd highly suggest you play with QueryOVer if this is possible in your case (bet possible means: you want something as easy/familiar as LINQ, but you do not have to use/expose IQueryable<> interface).
It has Futures() and it seems the best query way to go for most queries in NH 3.0, unless you have specific reasons to use others (Let the "there are so many ways and it depends on your situation ..." replies begin :)).

 

Mohamed Meligy

Fabio Maulo

unread,
Aug 28, 2010, 8:47:17 AM8/28/10
to nhu...@googlegroups.com
On Sat, Aug 28, 2010 at 5:51 AM, Mohamed Meligy <eng.m...@gmail.com> wrote:
I'd highly suggest you play with QueryOVer if this is possible in your case (bet possible means: you want something as easy/familiar as LINQ, but you do not have to use/expose IQueryable<> interface).
It has Futures() and it seems the best query way to go for most queries in NH 3.0, unless you have specific reasons to use others (Let the "there are so many ways and it depends on your situation ..." replies begin :)).

Yes Mohamed!!
Exactly an half-dozen ways to query your domain ;)

Welcome to the world of options.
Welcome to NHibernate 3!!!

-- 
Fabio Wind Maulo

Sal

unread,
Aug 28, 2010, 8:52:33 AM8/28/10
to nhusers
OK, well I will look into that. The idea is to get something friction-
less for simple scenarios where you are doing,for example, paging and
sorting on a UI, and want to push those queries through to NH in an
easy manner. We were doing NH linq queries, combined with dynamic
queryable (for sorting based off the string name of a field). I wanted
to try to use futures to wrap the query for the data and the query for
the total records into one DB call.That was trivial with criteria, but
not so much with linq.

I will have to look into queryover.



On Aug 28, 4:51 am, Mohamed Meligy <eng.mel...@gmail.com> wrote:
> I'd highly suggest you play with QueryOVer if this is possible in your case
> (bet possible means: you want something as easy/familiar as LINQ, but you do
> not have to use/expose IQueryable<> interface).
> It has Futures() and it seems the best query way to go for most queries in
> NH 3.0, unless you have specific reasons to use others (Let the "there are
> so many ways and it depends on your situation ..." replies begin :)).
>
> *Mohamed Meligy*
> > > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to nhu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > .

Fabio Maulo

unread,
Aug 28, 2010, 10:34:14 AM8/28/10
to nhu...@googlegroups.com
btw you can add a ticket in our JIRA to support Future feature even for LINQ provider.

To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.




--
Fabio Maulo

Erick Lombardo Nuñez Aguilar

unread,
Oct 10, 2010, 8:59:48 PM10/10/10
to nhusers
the beta version of nh include ToFuture and ToFutureValue for Linq

My question is.... How can i do the example below in Linq:

var persons = s.CreateQuery("from Person")
.SetMaxResults(10)
.Future<Person>();

var personCount = s.CreateQuery("select count(*) from
Person")
.FutureValue<long>();

Thanks in advance
> > <nhusers%2Bunsu...@googlegroups.com<nhusers%252Buns...@googlegroups.com>
>
> > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to nhu...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > <nhusers%2Bunsu...@googlegroups.com<nhusers%252Buns...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to nhu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo
Reply all
Reply to author
Forward
0 new messages