public ParserResult ParseNameAndOrder(string sortPropertyParameter) { var opts = _optionsProvider.Provide(); string name = sortPropertyParameter; var indicatorIndex = sortPropertyParameter.IndexOf(opts.DescendingIndicator, StringComparison.Ordinal); bool descending = indicatorIndex != -1; var regex = new Regex(opts.StripCharsPattern); name = regex.Replace(name, string.Empty); return(new ParserResult(name, descending)); }
public LambdaExpression CreateExpression(Type elementType, string propertyName) { var names = propertyName.Split(_optionsProvider.Provide().NestedPropSeparator); var initial = LambdaExpressionBuilder.Create() .AddParameter(elementType) .AccessProperty(names[0]); initial = names.Skip(1).Aggregate(initial, (builder, prop) => builder.ThenProperty(prop)); var result = initial .FinishAccess() .Build(); if (!result.IsSuccessfull) { throw new BadMemberAccessException(string.Join('\n', result.Errors)); } return(result.Result); }