Esempio n. 1
0
        private static FilterClause CreateFilterClause(IEdmEntitySet entitySet, IEnumerable <KeyValuePair <String, Object> > keys)
        {
            ResourceRangeVariableReferenceNode refNode = OeEdmClrHelper.CreateRangeVariableReferenceNode(entitySet);
            var entityType = (IEdmEntityType)refNode.RangeVariable.TypeReference.Definition;

            var propertyValues = new List <KeyValuePair <IEdmStructuralProperty, Object> >();

            foreach (KeyValuePair <String, Object> keyValue in keys)
            {
                var property = (IEdmStructuralProperty)entityType.FindProperty(keyValue.Key);
                propertyValues.Add(new KeyValuePair <IEdmStructuralProperty, Object>(property, keyValue.Value));
            }

            return(new FilterClause(OeGetParser.CreateFilterExpression(refNode, propertyValues), refNode.RangeVariable));
        }
Esempio n. 2
0
        private static List <SingleValuePropertyAccessNode> GetOrderByProperties(IEdmModel edmModel, IEdmEntityType edmType, OrderByClause orderByClause, ApplyClause applyClause)
        {
            var keys = new List <SingleValuePropertyAccessNode>();
            GroupByTransformationNode groupByNode;

            if (applyClause != null && (groupByNode = applyClause.Transformations.OfType <GroupByTransformationNode>().SingleOrDefault()) != null)
            {
                foreach (GroupByPropertyNode node in groupByNode.GroupingProperties)
                {
                    if (node.Expression == null)
                    {
                        keys.AddRange(node.ChildTransformations.Select(n => (SingleValuePropertyAccessNode)n.Expression));
                    }
                    else
                    {
                        keys.Add((SingleValuePropertyAccessNode)node.Expression);
                    }
                }
            }
            else
            {
                IEdmEntitySet entitySet = OeEdmClrHelper.GetEntitySet(edmModel, edmType);
                ResourceRangeVariableReferenceNode source = OeGetParser.CreateRangeVariableReferenceNode(entitySet);
                foreach (IEdmStructuralProperty key in edmType.Key())
                {
                    keys.Add(new SingleValuePropertyAccessNode(source, key));
                }
            }

            if (orderByClause == null)
            {
                return(keys);
            }

            for (; orderByClause != null; orderByClause = orderByClause.ThenBy)
            {
                var propertyNode = (SingleValuePropertyAccessNode)orderByClause.Expression;
                int i            = keys.FindIndex(p => p.Property == propertyNode.Property);
                if (i >= 0)
                {
                    keys.RemoveAt(i);
                }
            }
            return(keys);
        }
        internal OeQueryContext(IEdmModel edmModel, ODataUri odataUri,
                                IEdmEntitySet entitySet, IReadOnlyList <OeParseNavigationSegment> parseNavigationSegments,
                                bool isCountSegment, int pageSize, bool navigationNextLink, bool isDatabaseNullHighestValue,
                                OeMetadataLevel metadataLevel, ref Db.OeEntitySetAdapter entitySetAdapter)
        {
            EntitySetAdapter        = entitySetAdapter;
            EdmModel                = edmModel;
            ODataUri                = odataUri;
            EntitySet               = entitySet;
            ParseNavigationSegments = parseNavigationSegments;
            IsCountSegment          = isCountSegment;
            PageSize                = pageSize;
            NavigationNextLink      = navigationNextLink;
            MetadataLevel           = metadataLevel;

            if (pageSize > 0 || (odataUri.OrderBy != null && odataUri.Skip != null && odataUri.Top != null))
            {
                IEdmEntityType edmEntityType = OeGetParser.GetEntityType(odataUri.Path, parseNavigationSegments);
                SkipTokenParser = new OeSkipTokenParser(edmModel, edmEntityType, isDatabaseNullHighestValue, odataUri.OrderBy);
            }
        }
Esempio n. 4
0
 public async Task ExecuteQueryAsync(ODataUri odataUri, OeRequestHeaders headers, Stream responseStream, CancellationToken cancellationToken)
 {
     var parser = new Parsers.OeGetParser(EdmModel.GetEdmModel(odataUri.Path), _serviceProvider, ModelBoundProvider);
     await parser.ExecuteAsync(odataUri, headers, responseStream, cancellationToken).ConfigureAwait(false);
 }