Turns out to be a VB.NET issue. It took me quite a bit of time to track down. Check out the explanation here: http://jason.pettys.name/archive/2009/09/28/nhibernate-with-linq-error-with-string-comparisons-in-vb.net.aspx
On Sep 24, 2:53 am, JamesSpibey <[email protected]> wrote: > Thanks for your reply. Renaming the variable didn't fix it > unfortunately so I think I'm going to have to abandon the Linq > provider and go back to ICriteria. Shame, would've made things so much > cleaner > > On Sep 24, 5:43 am, alwin <[email protected]> wrote: > > > > > You can try to rename the district variable. Read somewhere that > > current linq2NH uses the variable names as identifiers, and you can > > get conflicts. > > > Dim districtToSearch As String = "YC" > > > Return From p In GetSession.Linq(Of Product)() _ > > Where p.Prices.Any(Function(x) x.District = > > districtToSearch) > > > When all else fails, you can use Criteria/HQL to at least get the > > result you want. > > > On 23 sep, 21:01, JamesSpibey <[email protected]> wrote: > > > > Can anyone help with this please? > > > > On Sep 21, 10:51 am, JamesSpibey <[email protected]> wrote: > > > > > 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 -~----------~----~----~----~------~----~------~--~---
