NH Linq and SelectMany

26 views
Skip to first unread message

Matthieu Guyonnet-Duluc

unread,
Sep 18, 2008, 6:03:30 PM9/18/08
to nhu...@googlegroups.com

I narrow my previous problem to this query :

IQueryable<Address> adresses = session.Linq<Subscriber>().Where(s => s.Id == new Guid("7af42422-ef0d-4368-a2a9-0bc2e9b0fd32")).SelectMany(s => s.Addresses);

I got a invalid cast exception (from Adress to Subscriber).

It seems that the SelectMany is not properly translated : in the method HandleSelectManyCall of NHibernateQueryTranslator this condition is not true for my call if (call.Arguments.Count == 3).
 
I've attached a console project with the query and the database used.
 
Matthieu


 

TestQuery.zip

Fabio Maulo

unread,
Sep 18, 2008, 7:28:06 PM9/18/08
to nhu...@googlegroups.com
JIRA ?

2008/9/18 Matthieu Guyonnet-Duluc <matth...@gmail.com>



--
Fabio Maulo

matthieuGD

unread,
Sep 19, 2008, 3:37:25 AM9/19/08
to nhusers

Tuna Toksöz

unread,
Sep 19, 2008, 4:40:27 AM9/19/08
to nhu...@googlegroups.com
I have tried to put a support for this, but i think it is a limitation of criteria.

On Fri, Sep 19, 2008 at 10:37 AM, matthieuGD <matth...@gmail.com> wrote:

done

http://jira.nhibernate.org/browse/NHLQ-16

Matthieu




--
Tuna Toksöz

Typos included to enhance the readers attention!

Matthieu Guyonnet-Duluc

unread,
Sep 19, 2008, 10:47:27 AM9/19/08
to nhu...@googlegroups.com
What do you mean by limitation of criteria ?
 
Matthieu

Tuna Toksöz

unread,
Sep 19, 2008, 10:50:13 AM9/19/08
to nhu...@googlegroups.com
You cannot project on a List
I mean

class MyEntity
{
    List<T> MyCollection{get;}
}


Since it is using Criteria api behind the scenes, and if I do it like this 
select x.Addresses

it will try to do SetProjection(Projections.Property("MyCollection")) which will not work

Does it? I may be wrong, don't know.

Fabio Maulo

unread,
Sep 19, 2008, 10:56:15 AM9/19/08
to nhu...@googlegroups.com
2008/9/19 Matthieu Guyonnet-Duluc <matth...@gmail.com>

What do you mean by limitation of criteria ?

The version of NHibernate.LINQ you are using (version hosted in NH.Contrib and previous in Rhino) is base on Criteria:
LINQ->Criteria->SQL
This mean that it suffer of the limits of Criteria API.

In the trunk we start a new project (NH2LINQ). Tuna Toksoz and Chad Lee are working on it.
The target of the new prj is allow you to use all features supported by LINQ and extend it with all feature supported by HQL (instead limit LINQ because CriteriaAPI).

--
Fabio Maulo

Matthieu Guyonnet-Duluc

unread,
Sep 19, 2008, 11:11:30 AM9/19/08
to nhu...@googlegroups.com
On Fri, Sep 19, 2008 at 4:56 PM, Fabio Maulo <fabio...@gmail.com> wrote:
 

In the trunk we start a new project (NH2LINQ). Tuna Toksoz and Chad Lee are working on it.
The target of the new prj is allow you to use all features supported by LINQ and extend it with all feature supported by HQL (instead limit LINQ because CriteriaAPI).

--
Fabio Maulo
 
Ok thanks you for the information ! With all the website and forums official or uniofficial between red hat, google groups, source forge, nhforge etc ...Sometimes  I'm kind of lost to find the correct documentation / news :)
 
Matthieu

Tuna Toksöz

unread,
Sep 19, 2008, 11:14:16 AM9/19/08
to nhu...@googlegroups.com
nhusers is the place to ask questions and NHForge is place for all nh-related stuff(wikis, blogs, etc).
sourceforge is for downloading releases.
Reply all
Reply to author
Forward
0 new messages