Ejemplo n.º 1
0
        /// <summary>
        /// Gets the query condition to determine whether the field value equals <paramref name="value"/>. This field may has multiple values separated by <paramref name="separator"/>.
        /// </summary>
        /// <param name="field"></param>
        /// <param name="value"></param>
        /// <param name="separator"></param>
        /// <param name="parameterSelector"></param>
        /// <returns></returns>
        public static ISqlExpression EqualWhenMultiple(ISqlExpression field, string value, string separator, Func <string, ISqlExpression> parameterSelector)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentException("value is null or empty.", "value");
            }
            if (string.IsNullOrWhiteSpace(separator))
            {
                throw new ArgumentException("separator is null or empty.", "separator");
            }

            return(field.Equal(parameterSelector(value)).Or(field.Like(parameterSelector(GetBeginLikeString(value + separator)))).Or(field.Like(parameterSelector(GetContainLikeString(separator + value + separator)))).Or(field.Like(parameterSelector(GetEndLikeString(separator + value)))));
        }