Skip to content

Commit

Permalink
Fixing removal of characters when no operation selected
Browse files Browse the repository at this point in the history
  • Loading branch information
David Greasley committed Sep 21, 2015
1 parent 1efd61f commit 42b3870
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Umbraco.Examine.Linq/ExpressionTreeVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ protected override Expression VisitMemberExpression(MemberExpression expression)

protected override Expression VisitConstantExpression(ConstantExpression expression)
{
string value = "";
string value = "";
string operation = "";

if(expression.Value is string)
{
Expand All @@ -151,7 +152,7 @@ protected override Expression VisitConstantExpression(ConstantExpression express
else if (expression.Value is DateTime)
{
var formattedDateTime = ((DateTime)expression.Value).ToString("yyyyMMddHHmmssfff", CultureInfo.InvariantCulture);//((DateTime)expression.Value).ToString("o");
string operation = currentPart.ToString().Substring(currentPart.Length - 2);
operation = currentPart.ToString().Substring(currentPart.Length - 2);
if (operation == "eq")
{
value = formattedDateTime;
Expand All @@ -176,7 +177,7 @@ protected override Expression VisitConstantExpression(ConstantExpression express
else if(expression.Value is int || expression.Value is double)
{
var formattedInt = expression.Value is double ? (Convert.ToInt64((double)expression.Value)).ToString() : ((int)expression.Value).ToString();
string operation = currentPart.ToString().Substring(currentPart.Length - 2);
operation = currentPart.ToString().Substring(currentPart.Length - 2);
if(operation == "eq")
{
value = formattedInt;
Expand All @@ -201,9 +202,11 @@ protected override Expression VisitConstantExpression(ConstantExpression express
else if (expression.Value is bool || expression.Value is Boolean)
value = ((bool)expression.Value) ? "1" : "0";
else
value = expression.Value.ToString();
value = expression.Value.ToString();

if (!string.IsNullOrEmpty(operation))
currentPart.Length = currentPart.Length - 2; //clear the last 2 characters

currentPart.Length = currentPart.Length - 2; //clear the last 2 characters
currentPart.Append(value);

return expression;
Expand Down

0 comments on commit 42b3870

Please sign in to comment.