public Expression CreateExpression(IQueryable query, OeConstantToVariableVisitor constantToVariableVisitor) { Expression expression; var expressionBuilder = new OeExpressionBuilder(EdmModel, EntitySetAdapter.EntityType); expression = Expression.Constant(null, typeof(IEnumerable <>).MakeGenericType(EntitySetAdapter.EntityType)); expression = expressionBuilder.ApplyNavigation(expression, ParseNavigationSegments); expression = expressionBuilder.ApplyFilter(expression, ODataUri.Filter); expression = expressionBuilder.ApplySkipToken(expression, SkipTokenParser, ODataUri.SkipToken); expression = expressionBuilder.ApplyAggregation(expression, ODataUri.Apply); expression = expressionBuilder.ApplySelect(expression, this); expression = expressionBuilder.ApplyOrderBy(expression, ODataUri.OrderBy); expression = expressionBuilder.ApplySkip(expression, ODataUri.Skip, ODataUri.Path); expression = expressionBuilder.ApplyTake(expression, ODataUri.Top, ODataUri.Path); expression = expressionBuilder.ApplyCount(expression, IsCountSegment); if (!IsCountSegment) { EntryFactory = CreateEntryFactory(expressionBuilder); } expression = constantToVariableVisitor.Translate(expression, expressionBuilder.Constants); if (ODataUri.QueryCount.GetValueOrDefault()) { CountExpression = CreateCountExpression(query, expression); } return(SourceVisitor.Translate(query, expression)); }
public Expression CreateExpression(OeConstantToVariableVisitor constantToVariableVisitor) { Expression expression; var expressionBuilder = new OeExpressionBuilder(EdmModel, EntitySetAdapter.EntityType); expression = Expression.Constant(null, typeof(IEnumerable <>).MakeGenericType(EntitySetAdapter.EntityType)); expression = expressionBuilder.ApplyNavigation(expression, ParseNavigationSegments); expression = expressionBuilder.ApplyFilter(expression, ODataUri.Filter); expression = expressionBuilder.ApplySkipToken(expression, SkipTokenNameValues, ODataUri.OrderBy, IsDatabaseNullHighestValue); expression = expressionBuilder.ApplyAggregation(expression, ODataUri.Apply); expression = expressionBuilder.ApplySelect(expression, this); expression = expressionBuilder.ApplyOrderBy(expression, ODataUri.OrderBy); expression = expressionBuilder.ApplySkip(expression, ODataUri.Skip, ODataUri.Path); expression = expressionBuilder.ApplyTake(expression, ODataUri.Top, ODataUri.Path); expression = expressionBuilder.ApplyCount(expression, IsCountSegment); if (!IsCountSegment) { EntryFactory = CreateEntryFactory(expressionBuilder); } if (SkipTokenNameValues != null) { SkipTokenAccessors = OeSkipTokenParser.GetAccessors(expression, ODataUri.OrderBy); } return(constantToVariableVisitor.Translate(expression, expressionBuilder.Constants)); }
public Expression CreateExpression(out IReadOnlyDictionary <ConstantExpression, ConstantNode> constants) { Initialize(); Expression expression; var expressionBuilder = new OeExpressionBuilder(_joinBuilder); IEdmEntitySet entitySet = OeEdmClrHelper.GetEntitySet(EdmModel, EntitySetAdapter.EntitySetName); expression = OeEnumerableStub.CreateEnumerableStubExpression(EntitySetAdapter.EntityType, entitySet); expression = expressionBuilder.ApplyNavigation(expression, ParseNavigationSegments); if (ODataUri.Apply == null) { expression = expressionBuilder.ApplyFilter(expression, ODataUri.Filter); expression = expressionBuilder.ApplySelect(expression, this); } else { expression = expressionBuilder.ApplyAggregation(expression, ODataUri.Apply); expression = expressionBuilder.ApplyFilter(expression, ODataUri.Filter); expression = expressionBuilder.ApplySkipToken(expression, SkipTokenNameValues, ODataUri.OrderBy, IsDatabaseNullHighestValue); //order by aggregation expression = expressionBuilder.ApplyOrderBy(expression, ODataUri.OrderBy); expression = expressionBuilder.ApplySkip(expression, ODataUri.Skip, ODataUri.Path); expression = expressionBuilder.ApplyTake(expression, ODataUri.Top, ODataUri.Path); } if (ODataUri.Path.LastSegment is CountSegment) { expression = expressionBuilder.ApplyCount(expression, true); } else { OePropertyAccessor[] skipTokenAccessors = OeSkipTokenParser.GetAccessors(expression, ODataUri.OrderBy, _joinBuilder); EntryFactory = CreateEntryFactory(expressionBuilder, skipTokenAccessors); } constants = expressionBuilder.Constants; return(expression); }
public Expression CreateExpression(IQueryable query, OeConstantToVariableVisitor constantToVariableVisitor) { Expression expression; var expressionBuilder = new OeExpressionBuilder(EdmModel, EntitySetAdapter.EntityType); expression = Expression.Constant(null, typeof(IEnumerable <>).MakeGenericType(EntitySetAdapter.EntityType)); expression = expressionBuilder.ApplyNavigation(expression, ParseNavigationSegments); expression = expressionBuilder.ApplyFilter(expression, ODataUri.Filter); expression = expressionBuilder.ApplyAggregation(expression, ODataUri.Apply); expression = expressionBuilder.ApplySelect(expression, ODataUri.SelectAndExpand, ODataUri.Path, Headers.MetadataLevel); expression = expressionBuilder.ApplyOrderBy(expression, ODataUri.OrderBy); expression = expressionBuilder.ApplySkip(expression, ODataUri.Skip, ODataUri.Path); expression = expressionBuilder.ApplyTake(expression, ODataUri.Top, ODataUri.Path); expression = expressionBuilder.ApplyCount(expression, IsCountSegment); if (!IsCountSegment) { EntryFactory = CreateEntryFactory(expressionBuilder); } expression = constantToVariableVisitor.Translate(expression, expressionBuilder.Constants); return(SourceVisitor.Translate(query, expression)); }
public Expression CreateExpression(OeConstantToVariableVisitor constantToVariableVisitor) { Expression expression; var expressionBuilder = new OeExpressionBuilder(JoinBuilder); IEdmEntitySet entitySet = OeEdmClrHelper.GetEntitySet(EdmModel, EntitySetAdapter.EntitySetName); expression = OeEnumerableStub.CreateEnumerableStubExpression(EntitySetAdapter.EntityType, entitySet); expression = expressionBuilder.ApplyNavigation(expression, ParseNavigationSegments); expression = expressionBuilder.ApplyFilter(expression, ODataUri.Filter); if (ODataUri.Apply == null) { expression = expressionBuilder.ApplySelect(expression, this); } else { expression = expressionBuilder.ApplySkipToken(expression, SkipTokenNameValues, ODataUri.OrderBy, IsDatabaseNullHighestValue); expression = expressionBuilder.ApplyAggregation(expression, ODataUri.Apply); expression = expressionBuilder.ApplyOrderBy(expression, ODataUri.OrderBy); expression = expressionBuilder.ApplySkip(expression, ODataUri.Skip, ODataUri.Path); expression = expressionBuilder.ApplyTake(expression, ODataUri.Top, ODataUri.Path); } expression = expressionBuilder.ApplyCount(expression, IsCountSegment); if (!IsCountSegment) { EntryFactory = CreateEntryFactory(expressionBuilder); } if (SkipTokenNameValues != null) { SkipTokenAccessors = OeSkipTokenParser.GetAccessors(expression, ODataUri.OrderBy, JoinBuilder); } return(constantToVariableVisitor.Translate(expression, expressionBuilder.Constants)); }