/// <summary> /// Infers resource sets and resource types corresponding to query operations in domain service. /// </summary> /// <param name="domainServiceDescription">Domain service description.</param> private void CollectResourceSets(DomainServiceDescription domainServiceDescription) { foreach (var operationEntry in domainServiceDescription.DomainOperationEntries) { // Only composable operations i.e. those that return IEnumerable<T> are expected to represent root resource sets. if (operationEntry.Operation == DomainOperation.Query && DomainDataServiceMetadata.IsRootQueryOperation(operationEntry)) { Type resourceInstanceType = operationEntry.AssociatedType; // There will always be an entity type associated with query operation, we need to make sure that we have all // the types in this type's hierarchy added to the provider types. ResourceType resourceType = this.CreateResourceTypeHierarchy(domainServiceDescription, resourceInstanceType); foreach (ResourceSet resourceSet in this.sets.Values) { Type resourceSetInstanceType = resourceSet.ResourceType.InstanceType; if (resourceSetInstanceType.IsAssignableFrom(resourceInstanceType) || resourceInstanceType.IsAssignableFrom(resourceSetInstanceType)) { throw new DomainDataServiceException((int)HttpStatusCode.InternalServerError, Resource.DomainDataService_MEST_NotAllowed); } } ResourceSet rs = new ResourceSet(resourceInstanceType.Name + ServiceUtils.ResourceSetPostFix, resourceType); this.sets.Add(operationEntry.Name, rs); } } }
/// <summary> /// Infers service operations from domain service description. /// </summary> /// <param name="domainServiceDescription">Domain service description.</param> private void CollectServiceOperations(DomainServiceDescription domainServiceDescription) { foreach (var operationEntry in domainServiceDescription.DomainOperationEntries) { DomainDataServiceOperation op = null; if ((operationEntry.Operation == DomainOperation.Query && !DomainDataServiceMetadata.IsRootQueryOperation(operationEntry)) || operationEntry.Operation == DomainOperation.Invoke) { op = this.CreateServiceOperation(operationEntry); } if (op != null) { this.serviceOperations.Add(op.Name, op); } } }