diff --git a/README.md b/README.md index 03faccaa..f5dca52d 100644 --- a/README.md +++ b/README.md @@ -135,15 +135,15 @@ but for example, if you need to just filter your data without paging or sorting | --------------------- | -------- | --------------------------------------------------------- | | Equal | `==` | `"FieldName ==Value"` | | NotEqual | `!=` | `"FieldName !=Value"` | -| LessThan | `<<` | `"FieldName <>` | `"FieldName >>Value"` | +| LessThan | `<` | `"FieldName < Value"` | +| GreaterThan | `>` | `"FieldName > Value"` | | GreaterThanOrEqual | `>=` | `"FieldName >=Value"` | | LessThanOrEqual | `<=` | `"FieldName <=Value"` | | Contains - Like | `=*` | `"FieldName =*Value"` | | NotContains - NotLike | `!*` | `"FieldName !*Value"` | | AND - && | `,` | `"FirstName ==Value, LastName ==Value2"` | | OR - || | | | "FirstName==Value|LastName==Value2" -| Parenthesis | `()` | "(FirstName=*Jo,Age<<30)|(FirstName!=Hn,Age>>30)" | +| Parenthesis | `()` | "(FirstName=*Jo,Age<30)|(FirstName!=Hn,Age>30)" | we can easily create complex queries using Parenthesis`()` with AND (`,`) + OR (`|`) operators. diff --git a/src/Benchmarks/Program.cs b/src/Benchmarks/Program.cs index 32105f19..12b9da1b 100644 --- a/src/Benchmarks/Program.cs +++ b/src/Benchmarks/Program.cs @@ -49,7 +49,7 @@ public void NativeLinQ() public void Gridify() { Ds .ApplyFiltering("Name=*a").Consume(Consumer); - Ds .ApplyFiltering("Id>>5").Consume(Consumer); + Ds .ApplyFiltering("Id>5").Consume(Consumer); Ds .ApplyFiltering("Name==Ali").Consume(Consumer); } diff --git a/src/Core/SyntaxTree/Lexer.cs b/src/Core/SyntaxTree/Lexer.cs index 73eca42b..8ac70065 100644 --- a/src/Core/SyntaxTree/Lexer.cs +++ b/src/Core/SyntaxTree/Lexer.cs @@ -53,14 +53,12 @@ public SyntaxToken NextToken() return new SyntaxToken(SyntaxKind.NotEqual, _position += 2, "!="); case '!' when peek == '*': return new SyntaxToken(SyntaxKind.NotLike, _position += 2, "!*"); - case '<' when peek == '<': - return new SyntaxToken(SyntaxKind.LessThan, _position += 2, "<<"); - case '>' when peek == '>': - return new SyntaxToken(SyntaxKind.GreaterThan, _position += 2, ">>"); - case '<' when peek == '=': - return new SyntaxToken(SyntaxKind.LessOrEqualThan, _position += 2, "<="); - case '>' when peek == '=': - return new SyntaxToken(SyntaxKind.GreaterOrEqualThan, _position += 2, ">="); + case '<': + return peek == '=' ? new SyntaxToken(SyntaxKind.LessOrEqualThan, _position += 2, "<=") : + new SyntaxToken(SyntaxKind.LessThan, _position++, "<"); + case '>': + return peek == '=' ? new SyntaxToken(SyntaxKind.GreaterOrEqualThan, _position += 2, ">=") : + new SyntaxToken(SyntaxKind.GreaterThan, _position++, ">"); } if (char.IsLetter(Current) && !_waitingForValue) diff --git a/test/Core.Tests/GridifyExtensionsShould.cs b/test/Core.Tests/GridifyExtensionsShould.cs index 1aa59515..4e03d58e 100644 --- a/test/Core.Tests/GridifyExtensionsShould.cs +++ b/test/Core.Tests/GridifyExtensionsShould.cs @@ -274,9 +274,9 @@ public void ApplyFiltering_CustomConvertor() public void ApplyFiltering_MultipleCondition() { var actual = _fakeRepository.AsQueryable() - .ApplyFiltering("name==Jack|name==Rose|id>>7") + .ApplyFiltering("name==Jack|name==Rose|id>=7") .ToList(); - var expected = _fakeRepository.Where(q => q.Name == "Jack" || q.Name == "Rose" || q.Id > 7).ToList(); + var expected = _fakeRepository.Where(q => q.Name == "Jack" || q.Name == "Rose" || q.Id >= 7).ToList(); Assert.Equal(expected.Count, actual.Count); Assert.Equal(expected, actual); Assert.True(actual.Any()); @@ -286,7 +286,7 @@ public void ApplyFiltering_MultipleCondition() public void ApplyFiltering_ComplexWithParenthesis() { var actual = _fakeRepository.AsQueryable() - .ApplyFiltering("(name=*J|name=*S),(Id<<5)") + .ApplyFiltering("(name=*J|name=*S),(Id<5)") .ToList(); var expected = _fakeRepository.Where(q => (q.Name.Contains("J") || q.Name.Contains("S")) && q.Id < 5).ToList(); Assert.Equal(expected.Count, actual.Count); @@ -298,7 +298,7 @@ public void ApplyFiltering_ComplexWithParenthesis() public void ApplyFiltering_NestedParenthesisWithSpace() { // we shouldn't add spaces for values - var gq = new GridifyQuery {Filter = " ( name =*J| ( name =*S , Id <<5 ) )"}; + var gq = new GridifyQuery {Filter = " ( name =*J| ( name =*S , Id <5 ) )"}; var actual = _fakeRepository.AsQueryable() .ApplyFiltering(gq) .ToList();