Skip to content

Commit

Permalink
Merge pull request #818 from mikependon/enum-allocation
Browse files Browse the repository at this point in the history
fixed some allocations
  • Loading branch information
mikependon committed May 4, 2021
2 parents e6a67f8 + 6c18548 commit 2bb2a08
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions RepoDb.Core/RepoDb/QueryField/ParseExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ private static ClassProperty GetTargetProperty<TEntity>(Field field)
/// <returns></returns>
internal static Operation GetOperation(ExpressionType expressionType)
{
if (Enum.TryParse(expressionType.ToString(), out Operation value))
return expressionType switch
{
return value;
}
throw new NotSupportedException($"Operation: Expression '{expressionType}' is currently not supported.");
ExpressionType.Equal => Operation.Equal,
ExpressionType.GreaterThan => Operation.GreaterThan,
ExpressionType.LessThan => Operation.LessThan,
ExpressionType.NotEqual => Operation.NotEqual,
ExpressionType.GreaterThanOrEqual => Operation.GreaterThanOrEqual,
ExpressionType.LessThanOrEqual => Operation.LessThanOrEqual,
_ => throw new NotSupportedException($"Operation: Expression '{expressionType}' is currently not supported.")
};
}

/// <summary>
Expand Down

0 comments on commit 2bb2a08

Please sign in to comment.