Class LikeComparesExtensions
- Namespace
- Ecng.ComponentModel
- Assembly
- Ecng.ComponentModel.dll
Provides extension methods for comparing string values using a specified comparison operator.
public static class LikeComparesExtensions
- Inheritance
-
LikeComparesExtensions
- Inherited Members
Methods
Like(string, string, ComparisonOperator?)
Determines if the specified string value matches a pattern based on the provided comparison operator.
public static bool Like(this string value, string like, ComparisonOperator? likeCompare)
Parameters
valuestringThe string value to evaluate.
likestringThe pattern to compare against.
likeCompareComparisonOperator?The comparison operator to use for the evaluation.
Returns
- bool
True if the value satisfies the comparison; otherwise, false.
Exceptions
- ArgumentNullException
Thrown when
valueis null.- ArgumentOutOfRangeException
Thrown when the comparison operator is not supported.
ToExpression(string, ComparisonOperator?)
Converts a pattern into an expression according to the specified comparison operator.
public static string ToExpression(this string like, ComparisonOperator? likeCompare = null)
Parameters
likestringThe pattern to convert.
likeCompareComparisonOperator?The comparison operator that determines how the expression is formed. Defaults to ComparisonOperator.In if null.
Returns
- string
A string expression representing the pattern.
Exceptions
- ArgumentNullException
Thrown when
likeis empty.- NotSupportedException
Thrown when the NotEqual operator is used.
- ArgumentOutOfRangeException
Thrown when the comparison operator is not supported.