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); }
/// <summary> /// Binds a root path segment. /// </summary> /// <param name="segmentToken">The segment to bind.</param> /// <returns>The bound node.</returns> private QueryNode BindRootSegment(SegmentQueryToken segmentToken) { Debug.Assert(segmentToken != null, "segmentToken != null"); Debug.Assert(segmentToken.Parent == null, "Only root segments should be allowed here."); Debug.Assert(!string.IsNullOrEmpty(segmentToken.Name), "!string.IsNullOrEmpty(segmentToken.Name)"); //// This is a metadata-only version of the RequestUriProcessor.CreateFirstSegment. if (segmentToken.Name == UriQueryConstants.MetadataSegment) { // TODO: $metadata segment parsing - no key values are allowed. throw new NotImplementedException(); } if (segmentToken.Name == UriQueryConstants.BatchSegment) { // TODO: $batch segment parsing - no key values are allowed. throw new NotImplementedException(); } // TODO: WCF DS checks for $count here first and fails. But not for the other $ segments. // which means other $segments get to SO resolution. On the other hand the WCF DS would eventually fail if an SO started with $. // Look for a service operation IEdmFunctionImport serviceOperation = this.model.TryResolveServiceOperation(segmentToken.Name); if (serviceOperation != null) { return this.BindServiceOperation(segmentToken, serviceOperation); } // TODO: Content-ID reference resolution. Do we actually do anything here or do we perform this through extending the metadata binder? // Look for an entity set. IEdmEntitySet entitySet = this.model.TryResolveEntitySet(segmentToken.Name); if (entitySet == null) { throw new ODataException(Strings.MetadataBinder_RootSegmentResourceNotFound(segmentToken.Name)); } EntitySetQueryNode entitySetQueryNode = new EntitySetQueryNode() { EntitySet = entitySet }; if (segmentToken.NamedValues != null) { return this.BindKeyValues(entitySetQueryNode, segmentToken.NamedValues); } return entitySetQueryNode; }
/// <summary> /// Translates an entity set node. /// </summary> /// <param name="entitySetNode">The entity set query node to translate.</param> /// <returns>Expression which evaluates to IQueryable<T> where T is the InstanceType of the type of the entity set.</returns> protected abstract Expression TranslateEntitySet(EntitySetQueryNode entitySetNode);
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; }