-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #440 from mk3008/439-typesafe-query-builder-review…
…-window-functions Supports window functions
- Loading branch information
Showing
7 changed files
with
568 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Linq.Expressions; | ||
|
||
namespace Carbunql.TypeSafe.Extensions; | ||
|
||
public static class ExpresionExtension | ||
{ | ||
public static string ToValue(this Expression exp, Func<string, object?, string> addParameter) | ||
{ | ||
if (exp is MemberExpression mem) | ||
{ | ||
return mem.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is ConstantExpression ce) | ||
{ | ||
return ce.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is NewExpression ne) | ||
{ | ||
return ne.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is BinaryExpression be) | ||
{ | ||
return be.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is UnaryExpression ue) | ||
{ | ||
return ue.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is MethodCallExpression mce) | ||
{ | ||
return mce.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is ConditionalExpression cnd) | ||
{ | ||
return cnd.ToValue(ToValue, addParameter); | ||
} | ||
else if (exp is ParameterExpression prm) | ||
{ | ||
return prm.ToValue(ToValue, addParameter); | ||
} | ||
|
||
throw new InvalidProgramException(exp.ToString()); | ||
} | ||
} |
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
Oops, something went wrong.