我这里有一个lambda表达式,目的是让我们数据库中的所有人都返回名字,姓氏,注册号码或与用户提供的搜索输入相匹配的电话号码。出于某种原因,当尝试进行此搜索时,我得到了一个长时间神秘的NHibernate错误(在底部)。只有当我的代码中包含该电话号码搜索,其他搜索工作正常,并且电话号码搜索工作正常时,才会发生这种情况。电话号码是电话的IList,它们的号码是一个字符串。根据字符串处理此搜索的任何建议或可能更好的方法?感谢。
x =>
(x.Person.FirstName.StartsWith(searchInput)) ||
(x.Person.LastName.StartsWith(searchInput)) ||
(x.RegistrationNumber.StartsWith(searchInput)) ||
(x.Person.PhoneNumbers.Any(s => s.Number.StartsWith(searchInput)))
);
09/16/2013 17:16:44 键入:NHibernate.QueryException,NHibernate,Version = 3.1.0.4000,Culture = neutral,PublicKeyToken = aa95f207798dfdb4 消息:无法解析属性:Number of:OeSystem.Domain.User.Person [.OrderBy [OeSystem.Domain.Member.Member,System.String](。[Where [OeSystem.Domain.Member.Member](NHibernate.Linq。 NhQueryable`1 [OeSystem.Domain.Member.Member],Quote((x,)=>(OrElse(OrElse)(OrElse(OrElse(x.Person.FirstName.StartsWith(p1,),x.Person.LastName.StartsWith (p2,)),),x.RegistrationNumber.StartsWith(p3,)),. Any [OeSystem.Domain.Address.Phone](x.Person.PhoneNumbers,(s,)=>(s.Number.StartsWith (p4,)),)))),),引用((x,)=>(x.Person.LastName)),)]
来源:NHibernate
帮助链接: QueryString:.OrderBy [OeSystem.Domain.Member.Member,System.String](。其中[OeSystem.Domain.Member.Member](NHibernate.Linq.NhQueryable
1[OeSystem.Domain.Member.Member], Quote((x, ) => (OrElse(OrElse(OrElse(OrElse(x.Person.FirstName.StartsWith(p1, ), x.Person.LastName.StartsWith(p2, )), x.RegistrationNumber.StartsWith(p4, )), .Any[OeSystem.Domain.Address.Phone](x.Person.PhoneNumbers, (s, ) => (s.Number.StartsWith(p5, )), )))), ), Quote((x, ) => (x.Person.LastName)), ) Data : System.Collections.ListDictionaryInternal TargetSite : NHibernate.Type.IType ToType(System.String) HResult : -2146232832 Stack Trace : at NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(String propertyName) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Persister\Entity\AbstractPropertyMapping.cs:line 44 at NHibernate.Hql.Ast.ANTLR.Tree.FromElementType.GetPropertyType(String propertyName, String propertyPath) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Tree\FromElementType.cs:line 340 at NHibernate.Hql.Ast.ANTLR.Tree.DotNode.GetDataType() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Tree\DotNode.cs:line 269 at NHibernate.Hql.Ast.ANTLR.Tree.DotNode.Resolve(Boolean generateJoin, Boolean implicitJoin, String classAlias, IASTNode parent) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Tree\DotNode.cs:line 200 at NHibernate.Hql.Ast.ANTLR.Tree.FromReferenceNode.Resolve(Boolean generateJoin, Boolean implicitJoin, String classAlias) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Tree\FromReferenceNode.cs:line 57 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.Resolve(IASTNode node) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\HqlSqlWalker.cs:line 445 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.expr() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 6477 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.exprOrSubquery() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 6122 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 5409 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 4824 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 4548 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 1693 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 1510 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.collectionFunctionOrSubselect() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 6325 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 5809 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 4824 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 4775 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 4548 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 1693 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 1510 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 536 at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:line 435 at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:line 590 at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary
2替换,布尔浅,String collectionRole)in d:\ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Hql \ Ast \ ANTLR \ QueryTranslatorImpl.cs:第397行 at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast,String queryIdentifier,String collectionRole,Boolean shallow,IDictionary2 filters, ISessionFactoryImplementor factory) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs:line 43 at NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary
2 enabledFilters,ISessionFactoryImplementor factory)在d:\ CSharp \ NH \ NH \ nhibernate \ src中\ NHibernate \ Engine \ Query \ HQLExpressionQueryPlan.cs:第34行 在NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression,Boolean shallow,IDictionary2 enabledFilters) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\QueryPlanCache.cs:line 89 at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs:line 312 at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs:line 268 at NHibernate.Linq.NhQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 43 at NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression expression) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\NhQueryProvider.cs:line 103 at Remotion.Data.Linq.QueryableBase
1.GetEnumerator()in:line 0 在System.Collections.Generic.List1..ctor(IEnumerable
1个集合) 在System.Linq.Enumerable.ToList [TSource](IEnumerable`1 source) 在OeSystem.BusinessLogic.Member.Member。<> c_ DisplayClass13.b _12() 在Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManagerImpl.Process(Action action,String policyName)