/// <summary> /// Constructs a search condition with the specified key. /// </summary> /// <param name="key"></param> protected SearchConditionBase(string key) : base(key) { _test = SearchConditionTest.None; _values = new object[0]; _sortPosition = -1; // do not sort on this field _sortDirection = true; // default sort direction to ascending }
/// <summary> /// Copy constructor. /// </summary> /// <param name="other"></param> protected SearchConditionBase(SearchConditionBase other) : base(other) { // copy the values _values = (new List<object>(other._values)).ToArray(); _test = other._test; _sortPosition = other._sortPosition; _sortDirection = other._sortDirection; }
/// <summary> /// Copy constructor. /// </summary> /// <param name="other"></param> protected SearchConditionBase(SearchConditionBase other) : base(other) { // copy the values _values = (new List <object>(other._values)).ToArray(); _test = other._test; _sortPosition = other._sortPosition; _sortDirection = other._sortDirection; }
protected void SetCondition(SearchConditionTest test, params object[] values) { // do not set a condition if any value is null foreach (var val in values) { if (IsNullValue(val)) { throw new ArgumentNullException(); } } _test = test; _values = values; }
internal static HqlCondition GetCondition(string variable, SearchConditionTest test, object[] values) { switch (test) { case SearchConditionTest.Equal: return(EqualTo(variable, values[0])); case SearchConditionTest.NotEqual: return(NotEqualTo(variable, values[0])); case SearchConditionTest.Like: return(Like(variable, (string)values[0])); case SearchConditionTest.NotLike: return(NotLike(variable, (string)values[0])); case SearchConditionTest.Between: return(Between(variable, values[0], values[1])); case SearchConditionTest.In: return(In(variable, values)); case SearchConditionTest.NotIn: return(NotIn(variable, values)); case SearchConditionTest.LessThan: return(LessThan(variable, values[0])); case SearchConditionTest.LessThanOrEqual: return(LessThanOrEqual(variable, values[0])); case SearchConditionTest.MoreThan: return(MoreThan(variable, values[0])); case SearchConditionTest.MoreThanOrEqual: return(MoreThanOrEqual(variable, values[0])); case SearchConditionTest.NotNull: return(IsNotNull(variable)); case SearchConditionTest.Null: return(IsNull(variable)); default: throw new Exception(); // invalid } }
protected void SetCondition(SearchConditionTest test, params object[] values) { // do not set a condition if any value is null foreach (var val in values) { if (IsNullValue(val)) throw new ArgumentNullException(); } _test = test; _values = values; }
internal static HqlCondition GetCondition(string variable, SearchConditionTest test, object[] values) { switch (test) { case SearchConditionTest.Equal: return EqualTo(variable, values[0]); case SearchConditionTest.NotEqual: return NotEqualTo(variable, values[0]); case SearchConditionTest.Like: return Like(variable, (string)values[0]); case SearchConditionTest.NotLike: return NotLike(variable, (string)values[0]); case SearchConditionTest.Between: return Between(variable, values[0], values[1]); case SearchConditionTest.In: return In(variable, values); case SearchConditionTest.NotIn: return NotIn(variable, values); case SearchConditionTest.LessThan: return LessThan(variable, values[0]); case SearchConditionTest.LessThanOrEqual: return LessThanOrEqual(variable, values[0]); case SearchConditionTest.MoreThan: return MoreThan(variable, values[0]); case SearchConditionTest.MoreThanOrEqual: return MoreThanOrEqual(variable, values[0]); case SearchConditionTest.NotNull: return IsNotNull(variable); case SearchConditionTest.Null: return IsNull(variable); default: throw new Exception(); // invalid } }