NH 3.0 GA & WCF Data services -> LINQ & SelectMany

247 views
Skip to first unread message

Alexander Kot

unread,
Dec 6, 2010, 8:00:40 AM12/6/10
to nhusers
Hello

I have tried to combine NH 3.0 & WCF data services following this
article
http://weblogs.asp.net/cibrax/archive/2010/08/13/nhibernating-a-wcf-data-service.aspx

It works partially for requests like
http://localhost:2711/TestWcfDataService.svc/TestEntities
http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'.......')
http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'........')/Setup1
//This is reference to setup from main entity
http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'........')?$expand=Details1

but do not works for request
http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'0dd52f6c-1943-4013-a88e-3b63a1fbe11b')/Details1
//This is multiple details for main Entity

NH generates exception
[Remotion.Data.Linq.Parsing.ParserException] {"Could not parse
expression
'value(NHibernate.Linq.NhQueryable`1[FRPT.TestXModule.BL.TestEntity]).Where(element
=> (element.Id == 0dd52f6c-1943-4013-
a88e-3b63a1fbe11b)).SelectMany(element => Convert(element.Details1))':
This overload of the method 'System.Linq.Queryable.SelectMany' is
currently not supported, but you can register your own parser if
needed."} Remotion.Data.Linq.Parsing.ParserException

The same exception generated by next statement without any WCF DS
var l3 = ses.Query<TestEntity>().Where(s => s.Id == new
Guid("....")).SelectMany(s => s.Details1).ToList();

I see in dev groop that there is increase of activity in LINQ bug fix
& development
May be this issue can also be fixed/improved ?

This is the area where other ways for querying NHib could not be used.
To be possible to work with WCF data services could be big + for NH.

I also has fined related info about this
[NH-16]
http://groups.google.com/group/nhusers/browse_frm/thread/d4af2b588e8f2601/0460dddc26f0a902?lnk=gst&q=SelectMany#0460dddc26f0a902
and this discussion
[Other exception but the same problem]
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/fcdaca20-73ea-4abb-b70b-981fe2728351




Fabio Maulo

unread,
Dec 6, 2010, 9:24:25 AM12/6/10
to nhu...@googlegroups.com
WebOrb data services for RIA are completelly based on HQL (you can use
LINQ as option).
What you mean exactly with "not possible" ?

--
Fabio Maulo

> --
> 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.
>

Alexander Kot

unread,
Dec 6, 2010, 9:45:06 AM12/6/10
to nhusers
WebOrb works with HQL - it is great.
but
MS WCF Data Services (not RIA but OData) use Linq in it's programming
model for accessing data.
I mean that it is not possible to integrate NH with WCF DS other way,
then providing compatible Linq implementation.
And it is partially possible right now, but only partially.

Also this do not work with same exception:
var l3 = ses.Query<TestEntity>().Where(s => s.Id
== .....).SelectMany(s => s.Details1).ToList();



On Dec 6, 4:24 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> WebOrb data services for RIA are completelly based on HQL (you can use
> LINQ as option).
> What you mean exactly with "not possible" ?
>
> --
> Fabio Maulo
>
> El 06/12/2010, a las 10:00, Alexander Kot <alexander....@gmail.com> escribió:
>
> > Hello
>
> > I have tried to combine NH 3.0 & WCF data services following this
> > article
> >http://weblogs.asp.net/cibrax/archive/2010/08/13/nhibernating-a-wcf-d...
> >http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'.........
> >        //This is reference to setup from main entity
> >http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'.........
>
> > but do not works for request
> >http://localhost:2711/TestWcfDataService.svc/TestEntities(guid'0dd52f...
> >        //This is multiple details for main Entity
>
> > NH generates exception
> > [Remotion.Data.Linq.Parsing.ParserException]    {"Could not parse
> > expression
> > 'value(NHibernate.Linq.NhQueryable`1[FRPT.TestXModule.BL.TestEntity]).Where(element
> > => (element.Id == 0dd52f6c-1943-4013-
> > a88e-3b63a1fbe11b)).SelectMany(element => Convert(element.Details1))':
> > This overload of the method 'System.Linq.Queryable.SelectMany' is
> > currently not supported, but you can register your own parser if
> > needed."}    Remotion.Data.Linq.Parsing.ParserException
>
> > The same exception generated by next statement without any WCF DS
> > var l3 = ses.Query<TestEntity>().Where(s => s.Id == new
> > Guid("....")).SelectMany(s => s.Details1).ToList();
>
> > I see in dev groop that there is increase of activity in LINQ bug fix
> > & development
> > May be this issue can also be fixed/improved ?
>
> > This is the area where other ways for querying NHib could not be used.
> > To be possible to work with WCF data services could be big + for NH.
>
> > I also has fined related info about this
> > [NH-16]
> >http://groups.google.com/group/nhusers/browse_frm/thread/d4af2b588e8f...
> > and this discussion
> > [Other exception but the same problem]
> >http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/t...

Alexander Kot

unread,
Dec 6, 2010, 9:58:21 AM12/6/10
to nhusers
Sorry but in original post example WCF DS links was converted to
redirects
It must be:

Works for
--h t t p: //localhost: 2711 / TestWcfDataService.svc/TestEntities
//All entities
--h t t p: //localhost: 2711 / TestWcfDataService.svc/
TestEntities(guid'...')
//1 entity
--h t t p: //localhost: 2711 / TestWcfDataService.svc/
TestEntities(guid'........')/Setup1
//Navigate to setup entity linked to specified entity
--h t t p: //localhost: 2711 / TestWcfDataService.svc/
TestEntities(guid'........')?$expand=Details1
//Main entity and expanded details (eager load)

But do not works for
--h t t p: //localhost: 2711/ TestWcfDataService.svc/
TestEntities(guid'.......')/Details1
//Navigate to Details linked to specified entity (Details lazy
load)

Alexander Kot

unread,
Dec 10, 2010, 7:49:45 AM12/10/10
to nhu...@googlegroups.com
When rebuilding NH with  Remotion - 1.13.85
exception has changed to

Internal in debugger:
"No corresponding expression node type was registered for method 'System.Linq.Queryable.SelectMany'.

Returned to browser:
<message>Could not parse expression 'value(NHibernate.Linq.NhQueryable`1[FRPT.TestXModule.BL.TestEntity]).Where(element => (element.Id == 0dd52f6c-1943-4013-a88e-3b63a1fbe11b)).SelectMany(element => Convert(element.Details1))': This overload of the method 'System.Linq.Queryable.SelectMany' is currently not supported.</message>
  <type>Remotion.Data.Linq.Parsing.ParserException</type>

So will wait when Remotion will implement this feature....

Fabian Schmied

unread,
Dec 10, 2010, 9:25:23 AM12/10/10
to nhu...@googlegroups.com
So will wait when Remotion will implement this feature....
 
Here's our JIRA entry for this feature: https://www.re-motion.org/jira/browse/RM-3551.
I hope to implement it some time around Christmas, but can't promise anything.
 
Regards,
Fabian

Alexander Kot

unread,
Mar 29, 2011, 9:01:44 AM3/29/11
to nhu...@googlegroups.com
Hello all
in NH 3.1 SelectMany was fixed in Remotion
so this query works

var l3 = ses.Query<TestEntity>().Where(s => s.Id == new Guid("....")).SelectMany(s => s.Details1).ToList();

but this do not help for WCF Data Services request execution :(
Like
http :// localhost: 2711/TestWcfDataService.svc/TestEntities(guid'0dd52f6c-1943-4013-a88e-3b63a1fbe11b')/Details1

I am not sure which component remotion or system.data.services.dll generate a little different LINQ for this (additional cast)
var l3 = ses.Query<TestEntity>().Where(s => s.Id == new Guid("....")).SelectMany(s => (IList<DetailType>)s.Details1).ToList();

execution of this query crashes with next exception
{"Could not load type s.Details1. Possible cause: the assembly was not loaded or not specified.":""}
it try creates instance by next type name: s.Details1

It seems for me that this behavior is similar to
http://216.121.112.228/browse/NH-2463 (also redundant typecast)
Next query also crashes in 3.1
var l3 = ses.Query<TestEntity>().Where(s => s.Id == new Guid("....")).SelectMany(s => (s.Details1 as IList<DetailType>)).ToList();

So Nhib 3.1 + WCF DS still cannot support
1) Select details by filtered master entity
2) Projections

Reply all
Reply to author
Forward
0 new messages