Thanks for the reply. That query was a mistake - I was trying to
simplify a larger query and the example I gave wasn't actually the
root problem.

Take for example the following query

Dim district As String = "YC"

Return From p In GetSession.Linq(Of Product)() _
          Where p.Prices.Any(Function(x) x.District = district)

x.District and district are both strings. However, the error I get is

[ArgumentException: Expression of type 'System.Int32' cannot be used
for return type 'System.Boolean']
   System.Linq.Expressions.Expression.ValidateLambdaArgs(Type
delegateType, Expression& body, ReadOnlyCollection`1 parameters)
+760320
   System.Linq.Expressions.Expression.Lambda(Type delegateType,
Expression body, IEnumerable`1 parameters) +57
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitLambda
(LambdaExpression lambda) +31
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
+379
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitList
(ReadOnlyCollection`1 original) +70
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitMethodCall
(MethodCallExpression m) +31
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
+341
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitLambda
(LambdaExpression lambda) +13
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
+379
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitUnary
(UnaryExpression u) +13
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
+75
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitList
(ReadOnlyCollection`1 original) +70
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitMethodCall
(MethodCallExpression m) +31
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
+341
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitList
(ReadOnlyCollection`1 original) +70
   NHibernate.Linq.Visitors.ExpressionVisitor.VisitMethodCall
(MethodCallExpression m) +31
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp)
+341
   NHibernate.Linq.NHibernateQueryProvider.TranslateExpression
(Expression expression) +38
   NHibernate.Linq.NHibernateQueryProvider.Execute(Expression
expression) +14
   NHibernate.Linq.QueryProvider.System.Linq.IQueryProvider.Execute
(Expression expression) +8
   System.Linq.Queryable.Count(IQueryable`1 source) +240

Am I trying to do something which isn't implemented?

Thanks

James

On Sep 18, 2:42 pm, Fabio Maulo <[email protected]> wrote:
> From p In GetSession.Linq(Of ProductPrice)() _
> Where p.WhseCode = 100 _
> Select p.ProductID
>
> 2009/9/18 JamesSpibey <[email protected]>
>
>
>
>
>
>
>
> > Hi,
>
> > I'm having difficulty querying a nullable field using  NH Linq. For
> > Example
>
> > From p In GetSession.Linq(Of ProductPrice)() _
> > Where p.WhseCode.Value = 100 _
> > Select p.ProductID
>
> > This fails with the following error
>
> > could not resolve property: WhseCode.Value of:
> > MyCompany.Data.ProductPrice
>
> > Clearly it can't match the .Value on the Nullable value back to the
> > mapped field on the object. Is there a way around this?
>
> > Thanks
>
> > James
>
> --
> Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to