Hi All, I've added the code below to SelectionTests.cs in NHibernate.Linq.Tests. I would expect this to work but instead get the exception below. I would expect this to work. Is there an issue with the Linq provider or am I misusing it. I'm sure I have done a similar thing in the past with Linq to SQL.
TIA, Brett private static UserDto Convert(User user) { return new UserDto(user.Id, user.Name); } [Test] public void CanSelectUsingMethod() { var query = session.Linq<User>().Select(u => Convert(u)); var list = query.ToList(); Assert.AreEqual(3, list.Count); } System.InvalidCastException: Unable to cast object of type 'NHibernate.Linq.Expressions.EntityExpression' to type 'NHibernate.Linq.Expressions.CollectionAccessExpression'. at NHibernate.Linq.Visitors.SelectArgumentsVisitor.VisitMethodCall (MethodCallExpression expr) in SelectArgumentsVisitor.cs: line 97 at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) in ExpressionVisitor.cs: line 70 at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit (Expression exp) in NHibernateExpressionVisitor.cs: line 29 at NHibernate.Linq.Visitors.RootVisitor.HandleSelectCall (MethodCallExpression call) in RootVisitor.cs: line 114 at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall (MethodCallExpression expr) in RootVisitor.cs: line 50 at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) in ExpressionVisitor.cs: line 70 at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit (Expression exp) in NHibernateExpressionVisitor.cs: line 29 at NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate (Expression expression, QueryOptions queryOptions) in NHibernateQueryTranslator.cs: line 40 at NHibernate.Linq.NHibernateQueryProvider.TranslateExpression (Expression expression) in NHibernateQueryProvider.cs: line 49 at NHibernate.Linq.NHibernateQueryProvider.Execute(Expression expression) in NHibernateQueryProvider.cs: line 54 at NHibernate.Linq.Query`1.GetEnumerator() in Query.cs: line 69 at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList<TSource>(IEnumerable`1 source) at NHibernate.Linq.Tests.SelectionTests.CanSelectUsingMethod() in SelectionTests.cs: line 70 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---