3

I am trying to query a parent User and then their UserRoleMappings. I have something similar to the below statement:

Dim userObj As User = session.Queryable(Of User)().Where(Function(x) x.username.Equals("someone")).FetchMany(Function(y) y.UserRoleMappings).SingleOrDefault()

When I try to run this statement I get the following exception:

A fetch request must be a simple member access expression; 'Convert(y.UserRoleMappings)' is a UnaryExpression instead. Parameter name: relatedObjectSelector

I can confirm that I got this to work in a C# Test Case, but unfortunately I need it to work in VB. Can anyone assist?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
ash
  • 45
  • 4
  • 2
    Could you possibly post your working C# code? – mxmissile Dec 17 '10 at 14:17
  • 1
    Here is the statement I am using in the c# test case: CUser userObj = session.Queryable().Where(o => o.username.Equals("someone")).FetchMany(y => y.UserRoleMappings).SingleOrDefault(); – ash Dec 19 '10 at 22:23
  • This is probably a problem with how they are converting the VB expression member... this is pretty common with libraries that don't test against VB.NET. The only way to fix it is to file a bug and hope they fix the offending code. – kamranicus Jun 01 '11 at 19:45
  • btw: This looks like Linq, not QueryOver. and I never saw session.Queryable<>, it;s usually session.Query<> – Variant Jun 02 '11 at 14:04
  • @PhilGood We ended up ditching this approach and going with Criteria. – ash Dec 19 '11 at 05:05
  • I've created a new issue on NHibernate issues tracker. https://nhibernate.jira.com/browse/NH-2966 – Phil Good Dec 20 '11 at 18:28

0 Answers0