/// <summary> /// Set a <see cref="ISearchCondition{T}"/> for a DICOM range matching string value. /// </summary> /// <param name="cond"></param> /// <param name="val"></param> public static void SetRangeCondition(ISearchCondition <string> cond, string val) { if (val.Length == 0) { return; } if (val.Contains("-")) { string[] vals = val.Split(new[] { '-' }); if (val.IndexOf('-') == 0) { cond.LessThanOrEqualTo(vals[1]); } else if (val.IndexOf('-') == val.Length - 1) { cond.MoreThanOrEqualTo(vals[0]); } else { cond.Between(vals[0], vals[1]); } } else { cond.EqualTo(val); } }
/// <summary> /// Set a <see cref="ISearchCondition{T}"/> for a DICOM range matching string value. /// </summary> /// <param name="cond"></param> /// <param name="val"></param> public static void SetRangeCondition(ISearchCondition<string> cond, string val) { if (val.Length == 0) return; if (val.Contains("-")) { string[] vals = val.Split(new[] { '-' }); if (val.IndexOf('-') == 0) cond.LessThanOrEqualTo(vals[1]); else if (val.IndexOf('-') == val.Length - 1) cond.MoreThanOrEqualTo(vals[0]); else cond.Between(vals[0], vals[1]); } else cond.EqualTo(val); }
private static void ApplyRange(ISearchCondition condition, bool hasLower, DateTime lower, bool hasUpper, DateTime upper) { // if both upper and lower bounded, use the between operator, otherwise use the >= and < operators // note that in SQL server, BETWEEN a AND b means a <= x < b (it is asymmetrical), however // this is not necessarily the case in other database servers... not much we can do about this. if (hasLower && hasUpper) { condition.Between(lower, upper); } else if (hasLower) { condition.MoreThanOrEqualTo(lower); } else if (hasUpper) { condition.LessThan(upper); } }