/// <summary> /// String representation of <see cref="FilterStatement{TPropertyType}" />. /// </summary> /// <returns></returns> public override string ToString() { var value = Value; IEnumerable <string> valueList; if (ValueIsList(out valueList)) { var matchType = new OperationHelper().FetchMatchType(Operation, MatchType); if (Operation == Operation.Between) { value = string.Join(" AND ", valueList); } else if (valueList.Count() == 1) { value = valueList.First(); } else { value = matchType + " ( \"" + string.Join("\", \"", valueList) + "\" )"; } } var operationHelper = new OperationHelper(); switch (operationHelper.NumberOfValuesAcceptable(Operation, MatchType)) { case 0: return(string.Format("{0} {1}", PropertyId, Operation)); default: return(string.Format("{0} {1} {2}", PropertyId, Operation, value)); } }
private void ValidateNumberOfValues(OperationHelper helper) { var numberOfValues = helper.NumberOfValuesAcceptable(Operation, MatchType); if (numberOfValues != -1 && CountValues() != numberOfValues) { throw new WrongNumberOfValuesException(Operation); } }
private void ValidateNumberOfValues(OperationHelper helper) { var numberOfValues = helper.NumberOfValuesAcceptable(Operation); var failsForSingleValue = numberOfValues == 1 && Value2 != null && !Value2.Equals(default(TPropertyType)); var failsForNoValueAtAll = numberOfValues == 0 && Value != null && Value2 != null && (!Value.Equals(default(TPropertyType)) || !Value2.Equals(default(TPropertyType))); if (failsForSingleValue || failsForNoValueAtAll) { throw new WrongNumberOfValuesException(Operation); } }
/// <summary> /// String representation of <see cref="FilterStatement{TPropertyType}" />. /// </summary> /// <returns></returns> public override string ToString() { var operationHelper = new OperationHelper(); switch (operationHelper.NumberOfValuesAcceptable(Operation)) { case 0: return(string.Format("{0} {1}", PropertyId, Operation)); case 2: return(string.Format("{0} {1} {2} And {3}", PropertyId, Operation, Value, Value2)); default: return(string.Format("{0} {1} {2}", PropertyId, Operation, Value)); } }
/// <summary> /// String representation of <see cref="FilterStatement{TPropertyType}" />. /// </summary> /// <returns></returns> public override string ToString() { var operationHelper = new OperationHelper(); switch (operationHelper.NumberOfValuesAcceptable(Operation)) { case 0: return($"{PropertyId} {Operation}"); case 2: return($"{PropertyId} {Operation} {Value} And {Value2}"); default: return($"{PropertyId} {Operation} {Value}"); } }