I've been facing this issue where,the following query throw an exception.
public override IQueryable<Permission> GetPermissionsQuery(IQueryable<Permission> permissionQuery, Contract entity, Guid organizationUnitPermissionAssigneeId, IEnumerable<Guid> rolePermissionAssigneeIds, Guid userPermissionAssigneeId)
{
var contractId = entity.Id;
var rights = this._DataContext.Query<Right>().ToFutureResults();
var assigneePermissions = new List<IEnumerable<Permission>>();
assigneePermissions.Add(this.GetUnscopedPermissionsForAssignee(userPermissionAssigneeId));
foreach (var rolePermissionAssigneeId in rolePermissionAssigneeIds)
assigneePermissions.Add(this.GetUnscopedPermissionsForAssignee(rolePermissionAssigneeId));
assigneePermissions.Add(this.GetUnscopedPermissionsForAssignee(organizationUnitPermissionAssigneeId));
assigneePermissions.Add(this.GetScopedPermissionsForContract(contractId, userPermissionAssigneeId));
foreach (var rolePermissionAssigneeId in rolePermissionAssigneeIds)
assigneePermissions.Add(this.GetScopedPermissionsForContract(contractId, rolePermissionAssigneeId));
assigneePermissions.Add(this.GetScopedPermissionsForContract(contractId, organizationUnitPermissionAssigneeId));
var permissions = new List<Permission>();
assigneePermissions.ForEach(assigneePermission =>
{
assigneePermission.ToList().ForEach(permission =>
{
if (!permissions.Any(x => Object.Equals(x.Right, permission.Right))) permissions.Add(permission);
});
});
return permissions
.Where(x => x.Value == PermissionValue.Allow.ToString() &&
(x.PrerequisiteRight == null ||
(permissions.Any(y => x.PrerequisiteRight == y.Right && y.Value == PermissionValue.Allow.ToString()))))
.ToArray()
.AsQueryable();
}
--------------------------------------------------------------------------------------------
The exception
2014-01-27 15:24:07 [/LM/W3SVC/1/ROOT/ContractDirector-1-130352832415266000][69] FATAL General - Unhandled Exception
NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown.
at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()
at NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse()
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
at NHibernate.Impl.MultiQueryImpl.AggregateQueriesInformation()
at NHibernate.Impl.MultiQueryImpl.CreateCombinedQueryParameters()
at NHibernate.Impl.MultiQueryImpl.List()
at NHibernate.Impl.FutureQueryBatch.GetResultsFrom(IMultiQuery multiApproach)
at NHibernate.Impl.FutureBatch`2.GetResults()
at NHibernate.Impl.FutureBatch`2.get_Results()
at NHibernate.Impl.FutureBatch`2.GetCurrentResult[TResult](Int32 currentIndex)
at NHibernate.Impl.FutureBatch`2.<>c__DisplayClass4`1.<GetEnumerator>b__3()
at NHibernate.Impl.DelayedEnumerator`1.<get_Enumerable>d__0.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at Upside.Clm.Contracts.Security.ContextFilterStrategies.ContractUserContextFilterStrategy.GetPermissionsQuery(IQueryable`1 permissionQuery, Contract entity, Guid organizationUnitPermissionAssigneeId, IEnumerable`1 rolePermissionAssigneeIds, Guid userPermissionAssigneeId)
at Upside.Clm.Security.Domain.Services.ContextFilterStrategy`1.GetPermissionsQuery(IQueryable`1 permissionQuery, TEntity entity, IUpsidePrincipal principal)