Пример #1
0
        public void ProcessQuery(QueryDescriptorQueryNode query)
        {
            _sparqlModel = new SparqlModel();
            switch (query.Query.Kind)
            {
            case QueryNodeKind.EntitySet:
                ProcessNode(query.Query as EntitySetQueryNode);
                break;

            case QueryNodeKind.KeyLookup:
                ProcessRoot(query.Query as KeyLookupQueryNode);
                break;

            case QueryNodeKind.Filter:
                var entityType = (query.Query as FilterQueryNode).ItemType;
                var instances  = AssertInstancesVariable(entityType);
                _entitySetVariable = instances;
                ProcessFilter(query.Query as FilterQueryNode);
                _sparqlModel.AddSelectVariable(instances, entityType.FullName(), true);
                _sparqlModel.IsDescribe = true;
                break;

            case QueryNodeKind.Top:
            case QueryNodeKind.Skip:
                ProcessNode(query.Query);
                break;

            case QueryNodeKind.Segment:
                var navigation = query.Query as NavigationPropertyNode;
                var finalVar   = ProcessNode(navigation);
                _sparqlModel.AddSelectVariable(
                    finalVar.ToString(),
                    navigation.TypeReference.FullName(),
                    navigation.NavigationProperty.OwnMultiplicity() == EdmMultiplicity.Many);
                _sparqlModel.IsDescribe = true;
                break;

            default:
                throw new NotImplementedException("No processing implemented for " + query.Query.Kind);
            }

            // Apply page size limit
            if (!_sparqlModel.Limit.HasValue || _sparqlModel.Limit.Value > _maxPageSize)
            {
                _sparqlModel.OriginalLimit = _sparqlModel.Limit;
                _sparqlModel.Limit         = _maxPageSize;
            }
        }
Пример #2
0
        public void ProcessQuery(QueryDescriptorQueryNode query)
        {
            _sparqlModel = new SparqlModel();
            switch (query.Query.Kind)
            {
                case QueryNodeKind.EntitySet:
                    ProcessNode(query.Query as EntitySetQueryNode);
                    break;
                case QueryNodeKind.KeyLookup:
                    ProcessRoot(query.Query as KeyLookupQueryNode);
                    break;
                case QueryNodeKind.Filter:
                    var entityType = (query.Query as FilterQueryNode).ItemType;
                    var instances = AssertInstancesVariable(entityType);
                    _entitySetVariable = instances;
                    ProcessFilter(query.Query as FilterQueryNode);
                    _sparqlModel.AddSelectVariable(instances, entityType.FullName(), true);
                    _sparqlModel.IsDescribe = true;
                    break;
                case QueryNodeKind.Top:
                case QueryNodeKind.Skip:
                    ProcessNode(query.Query);
                    break;
                case QueryNodeKind.Segment:
                    var navigation = query.Query as NavigationPropertyNode;
                    var finalVar = ProcessNode(navigation);
                    _sparqlModel.AddSelectVariable(
                        finalVar.ToString(), 
                        navigation.TypeReference.FullName(),
                        navigation.NavigationProperty.OwnMultiplicity() == EdmMultiplicity.Many);
                    _sparqlModel.IsDescribe = true;
                    break;
                default:
                    throw new NotImplementedException("No processing implemented for " + query.Query.Kind);
            }

            // Apply page size limit
            if (!_sparqlModel.Limit.HasValue || _sparqlModel.Limit.Value > _maxPageSize)
            {
                _sparqlModel.OriginalLimit = _sparqlModel.Limit;
                _sparqlModel.Limit = _maxPageSize;
            }
        }
Пример #3
0
        private string ProcessNode(EntitySetQueryNode entitySet)
        {
            var entitySetType = _map.GetUriForType(entitySet.EntitySet.ElementType.FullName());

            if (entitySetType == null)
            {
                // Throw exception
            }
            var instancesVariable = _sparqlModel.NextVariable();

            _sparqlModel.RootGraphPattern.Add(
                new TriplePattern(
                    new VariablePatternItem(instancesVariable),
                    new UriPatternItem("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
                    new UriPatternItem(entitySetType)
                    ));
            _sparqlModel.AddSelectVariable(instancesVariable, entitySet.ItemType.FullName(), true);
            _sparqlModel.IsDescribe = true;
            return(instancesVariable);
        }