コード例 #1
0
 private void UpdateOrderingInfoWithSkipTokenWrapper(Type resultWrapperType)
 {
     OrderingInfo info = new OrderingInfo(true);
     ParameterExpression expression = Expression.Parameter(resultWrapperType, "w");
     foreach (OrderingExpression expression2 in this.topLevelOrderingInfo.OrderingExpressions)
     {
         LambdaExpression expression3 = (LambdaExpression) expression2.Expression;
         Expression body = ParameterReplacerVisitor.Replace(expression3.Body, expression3.Parameters[0], Expression.MakeMemberAccess(expression, resultWrapperType.GetProperty("ExpandedElement")));
         info.Add(new OrderingExpression(Expression.Lambda(body, new ParameterExpression[] { expression }), expression2.IsAscending));
     }
     this.topLevelOrderingInfo = info;
 }
コード例 #2
0
        private ExpandSegmentCollection CheckSingleExpandPath(List<string> path)
        {
            ResourceType targetResourceType = this.description.TargetResourceType;
            ResourceSetWrapper targetContainer = this.description.LastSegmentInfo.TargetContainer;
            ExpandSegmentCollection segments = new ExpandSegmentCollection(path.Count);
            bool flag = false;
            bool previousSegmentIsTypeSegment = false;
            for (int i = 0; i < path.Count; i++)
            {
                string propertyName = path[i];
                ResourcePropertyKind stream = ResourcePropertyKind.Stream;
                ResourceProperty navigationProperty = targetResourceType.TryResolvePropertyName(propertyName, stream);
                if (navigationProperty == null)
                {
                    ResourceType type2 = WebUtil.ResolveTypeIdentifier(this.service.Provider, propertyName, targetResourceType, previousSegmentIsTypeSegment);
                    if (type2 == null)
                    {
                        if (targetResourceType.IsOpenType)
                        {
                            throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.OpenNavigationPropertiesNotSupportedOnOpenTypes(propertyName));
                        }
						throw DataServiceException.CreateSyntaxError(System.Data.Services.Strings.RequestUriProcessor_PropertyNotFound(targetResourceType.FullName, propertyName));
                    }
                    this.description.VerifyProtocolVersion(RequestDescription.Version3Dot0, this.service);
                    targetResourceType = type2;
                    previousSegmentIsTypeSegment = true;
                }
                else
                {
                    previousSegmentIsTypeSegment = false;
                    if (navigationProperty.TypeKind == ResourceTypeKind.EntityType)
                    {
                        targetContainer = this.service.Provider.GetContainer(targetContainer, targetResourceType, navigationProperty);
                        if (targetContainer == null)
                        {
                            throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.BadRequest_InvalidPropertyNameSpecified(navigationProperty.Name, targetResourceType.FullName));
                        }
                        bool singleResult = navigationProperty.Kind == ResourcePropertyKind.ResourceReference;
                        DataServiceConfiguration.CheckResourceRightsForRead(targetContainer, singleResult);
                        Expression filter = DataServiceConfiguration.ComposeQueryInterceptors(this.service, targetContainer);
                        if (((targetContainer.PageSize != 0) && !singleResult) && !this.IsCustomPaged)
                        {
                            OrderingInfo orderingInfo = new OrderingInfo(true);
                            ParameterExpression expression = Expression.Parameter(targetContainer.ResourceType.InstanceType, "p");
                            foreach (ResourceProperty property2 in targetContainer.GetKeyPropertiesForOrderBy())
                            {
                                Expression expression3;
                                if (property2.CanReflectOnInstanceTypeProperty)
                                {
                                    expression3 = Expression.Property(expression, targetContainer.ResourceType.GetPropertyInfo(property2));
                                }
                                else
                                {
                                    expression3 = Expression.Convert(Expression.Call(null, DataServiceProviderMethods.GetValueMethodInfo, expression, Expression.Constant(property2)), property2.Type);
                                }
                                orderingInfo.Add(new OrderingExpression(Expression.Lambda(expression3, new ParameterExpression[] { expression }), true));
                            }
                            segments.Add(new ExpandSegment(navigationProperty.Name, filter, targetContainer.PageSize, targetContainer, targetResourceType, navigationProperty, orderingInfo));
                            this.description.VerifyProtocolVersion(RequestDescription.Version2Dot0, this.service);
                            this.description.VerifyAndRaiseResponseVersion(RequestDescription.Version2Dot0, this.service);
                        }
                        else
                        {
                            if (!singleResult && this.IsCustomPaged)
                            {
                                this.CheckAndApplyCustomPaging(null);
                            }
                            segments.Add(new ExpandSegment(navigationProperty.Name, filter, this.service.Configuration.MaxResultsPerCollection, targetContainer, targetResourceType, navigationProperty, null));
                        }
                        this.description.UpdateAndCheckEpmFeatureVersion(targetContainer, this.service);
                        this.description.UpdateVersions(this.service.OperationContext.Host.RequestAccept, targetContainer, this.service);
                        flag = false;
                        targetResourceType = navigationProperty.ResourceType;
                    }
                    else
                    {
                        flag = true;
                    }
                }
            }
            if (previousSegmentIsTypeSegment)
            {
                throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_QueryParametersPathCannotEndInTypeIdentifier("$expand", targetResourceType.FullName));
            }
            if (!flag)
            {
                return segments;
            }
            return null;
        }