Open thechasboi opened 10 years ago
This is the error I get.
Specified method is not supported. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Specified method is not supported.
Source Error:
Line 466: }*/ Line 467: Line 468: searchResultsViewModel.SafetyEvents = queryEveny.Take(100).ToList(); Line 469: Line 470: return View("IndexEventResults", searchResultsViewModel);
Source File: c:\Projects\NMIS-IT\src\NASA.SMA.NMIS.Web.UI\Controllers\SearchController.cs Line: 468
Stack Trace:
[NotSupportedException: Specified method is not supported.]
NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.GetClassName(IASTNode querySource) +256
NHibernate.Hql.Ast.ANTLR.PolymorphicQuerySourceDetector.Process(IASTNode tree) +232
NHibernate.Hql.Ast.ANTLR.AstPolymorphicProcessor.Process() +142
NHibernate.Hql.Ast.ANTLR.AstPolymorphicProcessor.Process(IASTNode ast, ISessionFactoryImplementor factory) +129
NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary2 filters, ISessionFactoryImplementor factory) +227 NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary
2 filters, ISessionFactoryImplementor factory) +160
NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary2 enabledFilters, ISessionFactoryImplementor factory) +210 NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary
2 enabledFilters, ISessionFactoryImplementor factory) +120
NHibernate.Engine.Query.HQLExpressionQueryPlan..ctor(String expressionStr, IQueryExpression queryExpression, Boolean shallow, IDictionary2 enabledFilters, ISessionFactoryImplementor factory) +97 NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary
2 enabledFilters) +708
NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow) +294
NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression) +221
NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery) +296
NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) +83
NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) +75
Remotion.Linq.QueryableBase1.GetEnumerator() +212 System.Collections.Generic.List
1..ctor(IEnumerable1 collection) +446 System.Linq.Enumerable.ToList(IEnumerable
1 source) +80
NASA.SMA.NMIS.Web.UI.Controllers.SearchController.Index(SearchViewModel model) in c:\Projects\NMIS-IT\src\NASA.SMA.NMIS.Web.UI\Controllers\SearchController.cs:468
lambda_method(Closure , ControllerBase , Object[] ) +127
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +242 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +39
System.Web.Mvc.Async.AsyncControllerActionInvoker.1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.
If I feed a list of objects of type NHibernate.Linq.NhQueryable and use .Any on this object inside the nhibernate query it works fine but when I use an IList the .Any is not recognized as a method. Code below
I must preface with stating we are using Onion architecture and extracted nihibernate layer. There are interfaces that inherate from the repository wich inturn inherets from the extracted nhibernate methods. I will first include the .find which I am using to get the list by filtering from another list. We are also using dependency injection.
///
Finds this instance.
the first example works using the _contractorRepository is a repository object the contracts come from another repository query and returns nhibernate wrapped object/proxied list. _contractorRepository.Find().Where(x => contracts.Any(a => a.Contractor.Id == x.Id) && x.IsActive)
This result in a perfect set from the db.
The following is a query built for a search page. the entire query works except for this point. queryEveny = queryEveny.Where(x => userContracts.Any(a => a.Contractor.Id == x.Contract.Contractor.Id))
the userContracts is a list of contract objects like you would expect from an object but they are a plain IList. If I convert to an IQueryable I get different errors that eventually point to the fact the .Any is not a recognized function. I hope this makes sense.
Any thoughts on how to achieve this?
Thanks for the reply.