private FilterQueryContext GetQueryContexts(FilterQuery query, string parameterName) { var queryContext = new FilterQueryContext(query); var customQuery = _requestResourceDefinition?.GetCustomQueryFilter(query.Target); if (customQuery != null) { queryContext.IsCustom = true; queryContext.CustomQuery = customQuery; return(queryContext); } queryContext.Relationship = GetRelationship(parameterName, query.Relationship); var attribute = GetAttribute(parameterName, query.Attribute, queryContext.Relationship); if (queryContext.Relationship is HasManyAttribute) { throw new InvalidQueryStringParameterException(parameterName, "Filtering on one-to-many and many-to-many relationships is currently not supported.", $"Filtering on the relationship '{queryContext.Relationship.PublicRelationshipName}.{attribute.PublicAttributeName}' is currently not supported."); } if (!attribute.Capabilities.HasFlag(AttrCapabilities.AllowFilter)) { throw new InvalidQueryStringParameterException(parameterName, "Filtering on the requested attribute is not allowed.", $"Filtering on attribute '{attribute.PublicAttributeName}' is not allowed."); } queryContext.Attribute = attribute; return(queryContext); }
private FilterQueryContext GetQueryContexts(FilterQuery query, string parameterName) { var queryContext = new FilterQueryContext(query); var customQuery = _requestResourceDefinition?.GetCustomQueryFilter(query.Target); if (customQuery != null) { queryContext.IsCustom = true; queryContext.CustomQuery = customQuery; return(queryContext); } queryContext.Relationship = GetRelationship(parameterName, query.Relationship); var attribute = GetAttribute(parameterName, query.Attribute, queryContext.Relationship); if (!attribute.IsFilterable) { throw new InvalidQueryStringParameterException(parameterName, "Filtering on the requested attribute is not allowed.", $"Filtering on attribute '{attribute.PublicAttributeName}' is not allowed."); } queryContext.Attribute = attribute; return(queryContext); }
private FilterQueryContext GetQueryContexts(FilterQuery query) { var queryContext = new FilterQueryContext(query); if (_requestResourceDefinition != null) { var customQuery = _requestResourceDefinition.GetCustomQueryFilter(query.Target); if (customQuery != null) { queryContext.IsCustom = true; queryContext.CustomQuery = customQuery; return(queryContext); } } queryContext.Relationship = GetRelationship(query.Relationship); var attribute = GetAttribute(query.Attribute, queryContext.Relationship); if (attribute.IsFilterable == false) { throw new JsonApiException(400, $"Filter is not allowed for attribute '{attribute.PublicAttributeName}'."); } queryContext.Attribute = attribute; return(queryContext); }