-
-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for IsNullOrWhiteSpace operator in linq queries
- Loading branch information
1 parent
0e2158d
commit b089bc2
Showing
7 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Marten/Linq/Parsing/Methods/Strings/StringIsNullOrWhiteSpace.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Linq.Expressions; | ||
using Marten.Linq.Members; | ||
using Weasel.Postgresql.SqlGeneration; | ||
|
||
namespace Marten.Linq.Parsing.Methods.Strings; | ||
|
||
internal class StringIsNullOrWhiteSpace: IMethodCallParser | ||
{ | ||
public bool Matches(MethodCallExpression expression) | ||
{ | ||
return expression.Method.Name == nameof(string.IsNullOrWhiteSpace) | ||
&& expression.Method.DeclaringType == typeof(string); | ||
} | ||
|
||
public ISqlFragment Parse(IQueryableMemberCollection memberCollection, IReadOnlyStoreOptions options, | ||
MethodCallExpression expression) | ||
{ | ||
var locator = memberCollection.MemberFor(expression.Arguments[0]).RawLocator; | ||
|
||
return new WhereFragment($"({locator} IS NULL OR trim({locator}) = '')"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters