-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support some linq string functions in where conditions, fixes #499
- Loading branch information
1 parent
30c1b61
commit 817a9f0
Showing
4 changed files
with
201 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace InfluxDB.Client.Linq.Internal.Expressions { | ||
internal class StringFunction : IExpressionPart { | ||
private readonly string functionName; | ||
private readonly IEnumerable<IExpressionPart> expressionParts; | ||
private readonly IEnumerable<IExpressionPart> expressionPartsPar2; | ||
private readonly IEnumerable<IExpressionPart> expressionPartsPar3; | ||
|
||
internal StringFunction(string functionName, IEnumerable<IExpressionPart> expressionParts, IEnumerable<IExpressionPart> expressionPartsPar2, IEnumerable<IExpressionPart> expressionPartsPar3) { | ||
this.functionName = functionName; | ||
this.expressionParts = expressionParts; | ||
this.expressionPartsPar2 = expressionPartsPar2; | ||
this.expressionPartsPar3 = expressionPartsPar3; | ||
} | ||
|
||
public void AppendFlux(StringBuilder builder) { | ||
if (functionName != "string") | ||
builder.Append("strings."); | ||
builder.Append(functionName); | ||
builder.Append("(v: "); | ||
foreach (var expressionPart in expressionParts) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
if (functionName == "containsStr") | ||
{ | ||
builder.Append(", substr: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
else if (functionName == "hasPrefix") { | ||
builder.Append(", prefix: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
else if (functionName == "hasSuffix") { | ||
builder.Append(", suffix: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
else if (functionName == "replaceAll") { | ||
builder.Append(", t: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
builder.Append(", u: "); | ||
foreach (var expressionPart in expressionPartsPar3) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
builder.Append(")"); | ||
} | ||
} | ||
} |
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