diff --git a/src/Framework.OData.Tests.Unit/DateParsingTests.cs b/src/Framework.OData.Tests.Unit/DateParsingTests.cs index 3b0b12b3e..cc98c4ace 100644 --- a/src/Framework.OData.Tests.Unit/DateParsingTests.cs +++ b/src/Framework.OData.Tests.Unit/DateParsingTests.cs @@ -47,7 +47,7 @@ public void Setup() public void NotNullableDate__Month_Equal_Value_ElementFounded() { // Arrange - var query = "$top=70&$filter=month(StartDateNotNull) eq 9"; + var query = "$top=70&$filter=month(startDateNotNull) eq 9&$orderby=startDateNotNull"; // Act var res = this.ParseAndProcess(query); diff --git a/src/Framework.OData/Parser/Parsing/LambdaExpressionInternalParser.cs b/src/Framework.OData/Parser/Parsing/LambdaExpressionInternalParser.cs index 853260757..03b437712 100644 --- a/src/Framework.OData/Parser/Parsing/LambdaExpressionInternalParser.cs +++ b/src/Framework.OData/Parser/Parsing/LambdaExpressionInternalParser.cs @@ -16,10 +16,10 @@ internal class LambdaExpressionInternalParser : CharParsers private const char EscapeChar = (char)27; private const string PostEscapeChars = "'"; - private readonly NumberFormatInfo _numberFormatInfo; - private readonly ParameterExpression _rootParameter; - private readonly ParameterExpression _currentParameter; - private readonly ReadOnlyCollection _usedParameters; + private readonly NumberFormatInfo numberFormatInfo; + private readonly ParameterExpression rootParameter; + private readonly ParameterExpression currentParameter; + private readonly ReadOnlyCollection usedParameters; public LambdaExpressionInternalParser(NumberFormatInfo numberFormatInfo, ParameterExpression rootParameter, ParameterExpression currentParameter, ReadOnlyCollection usedParameters) @@ -29,10 +29,10 @@ public LambdaExpressionInternalParser(NumberFormatInfo numberFormatInfo, Paramet if (currentParameter == null) throw new ArgumentNullException(nameof(currentParameter)); if (usedParameters == null) throw new ArgumentNullException(nameof(usedParameters)); - this._numberFormatInfo = numberFormatInfo; - this._rootParameter = rootParameter; - this._currentParameter = currentParameter; - this._usedParameters = usedParameters; + this.numberFormatInfo = numberFormatInfo; + this.rootParameter = rootParameter; + this.currentParameter = currentParameter; + this.usedParameters = usedParameters; } @@ -63,7 +63,7 @@ private Parser GetMainParser(Func + select properties.Aggregate((Expression)this.currentParameter, (source, propertyPair) => propertyPair.Alias == null ? new PropertyExpression(source, propertyPair.PropertyName) : new SelectExpression(source, propertyPair.PropertyName, propertyPair.Alias)); @@ -368,17 +368,17 @@ private Parser> PropertyStartParameterE { get { - return this.StringIgnoreCase("it").Or(() => this.StringIgnoreCase("this")).Select(_ => Tuple.Create(this._currentParameter, true)) + return this.StringIgnoreCase("it").Or(() => this.StringIgnoreCase("this")).Select(_ => Tuple.Create(this.currentParameter, true)) .Or(() => from startElementName in this.PreSpaces(this.Variable) let startElementParameter = new ParameterExpression(startElementName) - where this._usedParameters.Contains(startElementParameter) + where this.usedParameters.Contains(startElementParameter) select Tuple.Create(startElementParameter, true)) - .Or(() => this.Return(Tuple.Create(this._currentParameter, false))); + .Or(() => this.Return(Tuple.Create(this.currentParameter, false))); } } @@ -521,7 +521,7 @@ private ParameterExpression GenerateAnonymousParameterExpression(string baseName let parameter = new ParameterExpression(name) - where !this._usedParameters.Contains(parameter) + where !this.usedParameters.Contains(parameter) select parameter; diff --git a/src/Framework.OData/Parser/Parsing/SelectOperationInternalParser.cs b/src/Framework.OData/Parser/Parsing/SelectOperationInternalParser.cs index edbc1b91e..6076d60d9 100644 --- a/src/Framework.OData/Parser/Parsing/SelectOperationInternalParser.cs +++ b/src/Framework.OData/Parser/Parsing/SelectOperationInternalParser.cs @@ -8,20 +8,20 @@ namespace Framework.OData; internal class SelectOperationInternalParser : CharParsers { - private readonly NumberFormatInfo _numberFormatInfo; + private readonly NumberFormatInfo numberFormatInfo; - private readonly ParameterExpression _rootParameter = ParameterExpression.Default; + private readonly ParameterExpression rootParameter = ParameterExpression.Default; - private readonly LambdaExpressionInternalParser _rootLambdaExpressionParser; + private readonly LambdaExpressionInternalParser rootLambdaExpressionParser; public SelectOperationInternalParser(NumberFormatInfo numberFormatInfo) { if (numberFormatInfo == null) throw new ArgumentNullException(nameof(numberFormatInfo)); - this._numberFormatInfo = numberFormatInfo; + this.numberFormatInfo = numberFormatInfo; - this._rootLambdaExpressionParser = new LambdaExpressionInternalParser(this._numberFormatInfo, this._rootParameter, this._rootParameter, new [] { this._rootParameter }.ToReadOnlyCollection()); + this.rootLambdaExpressionParser = new LambdaExpressionInternalParser(this.numberFormatInfo, this.rootParameter, this.rootParameter, new [] { this.rootParameter }.ToReadOnlyCollection()); } @@ -29,7 +29,7 @@ private LambdaExpression CreateRootLambda(Expression body) { if (body == null) throw new ArgumentNullException(nameof(body)); - return new LambdaExpression(body, new[] { this._rootParameter }); + return new LambdaExpression(body, new[] { this.rootParameter }); } @@ -88,7 +88,7 @@ from item in itemParser private Parser RootBodyParser { - get { return this._rootLambdaExpressionParser.RootBodyParser; } + get { return this.rootLambdaExpressionParser.RootBodyParser; } } private Parser FilterParser @@ -120,7 +120,7 @@ private Parser> ExpandsParser private Parser> SelectsParser { - get { return this.SepBy1(this._rootLambdaExpressionParser.PropertyPathParser.Select(this.CreateRootLambda), ','); } + get { return this.SepBy1(this.rootLambdaExpressionParser.PropertyPathParser.Select(this.CreateRootLambda), ','); } } private Parser RootLambdaExpressionParser diff --git a/src/Framework.OData/Typed/StandartExpressionBuilderExtensions.cs b/src/Framework.OData/Typed/StandartExpressionBuilderExtensions.cs index d159fb097..f452ac89c 100644 --- a/src/Framework.OData/Typed/StandartExpressionBuilderExtensions.cs +++ b/src/Framework.OData/Typed/StandartExpressionBuilderExtensions.cs @@ -28,13 +28,13 @@ public static SelectOperation ToTyped if (expressionBuilder == null) throw new ArgumentNullException(nameof(expressionBuilder)); if (selectOperation == null) throw new ArgumentNullException(nameof(selectOperation)); - var projectionSelectOperaton = expressionBuilder.ToTyped(selectOperation); + var projectionSelectOperation = expressionBuilder.ToTyped(selectOperation); - var baseSelectOperaton = projectionSelectOperaton.Covariance(); + var baseSelectOperation = projectionSelectOperation.Covariance(); - var standartSelectOperaton = baseSelectOperaton.Visit(new ExpandProjectionVisitor(typeof(TProjection))); + var standartSelectOperation = baseSelectOperation.Visit(new ExpandProjectionVisitor(typeof(TProjection))); - return standartSelectOperaton; + return standartSelectOperation; } @@ -60,20 +60,20 @@ private static SelectOrder ToTypedOrder property.PropertyType.IsInterface) + var accumVisitor = this.projectionType.GetReferencedTypes(property => property.PropertyType.IsInterface) .Select(refType => new OverrideCallInterfacePropertiesVisitor(refType)) .Concat(new ExpressionVisitor[] { ExpandPathVisitor.Value, ExpandExplicitPropertyVisitor.Value, OverrideCallInterfaceGenericMethodVisitor.Value }) .ToCyclic(); diff --git a/src/Framework.QueryLanguage/LambdaExpression.cs b/src/Framework.QueryLanguage/LambdaExpression.cs index 04d850198..7d294644d 100644 --- a/src/Framework.QueryLanguage/LambdaExpression.cs +++ b/src/Framework.QueryLanguage/LambdaExpression.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Reflection; using System.Runtime.Serialization; using Framework.Core; @@ -43,7 +44,13 @@ public LambdaExpression(Expression body, IEnumerable parame public Type ExtractTargetType() { - return this.ExtractPropertyPath(this.Body).Reverse().Aggregate(typeof(TDomainObject), (currentType, property) => currentType.GetMemberType(property.PropertyName, true)); + return this.ExtractPropertyPath(this.Body) + .Reverse() + .Aggregate( + (SExpressions.Expression)SExpressions.Expression.Parameter(typeof(TDomainObject)), + (currentExpr, property) => + SExpressions.Expression.PropertyOrField(currentExpr, property.PropertyName)) + .Type; } private IEnumerable ExtractPropertyPath(Expression currentNode) diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index f86a6bb91..d559c29ae 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2009-2024")] -[assembly: AssemblyVersion("22.5.8.0")] -[assembly: AssemblyFileVersion("22.5.8.0")] -[assembly: AssemblyInformationalVersion("22.5.8.0")] +[assembly: AssemblyVersion("22.5.9.0")] +[assembly: AssemblyFileVersion("22.5.9.0")] +[assembly: AssemblyInformationalVersion("22.5.9.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]