/// <summary> /// test column value match the condition. /// </summary> /// <param name="columnbytes"></param> /// <returns></returns> public virtual bool isMatch(byte[] columnbytes) { if (columnbytes == null) { return(false); } if (this.IsDateTime) { var coltime = DateTimeUtcHelper.ToDateTime(columnbytes); return(DateTimeUtcHelper.Compare(compareType, coltime, this.TargetDate)); } else if (this.IsString) { var currentValue = System.Text.Encoding.UTF8.GetString(columnbytes); if (currentValue != null) { currentValue = currentValue.Trim('\0'); currentValue = currentValue.Trim(); } return(Helper.StringHelper.Compare(this.compareType, currentValue, this.TargetString)); } else { switch (compareType) { case Comparer.EqualTo: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) == 0); case Comparer.GreaterThan: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) > 0); case Comparer.GreaterThanOrEqual: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) >= 0); case Comparer.LessThan: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) < 0); case Comparer.LessThanOrEqual: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) <= 0); case Comparer.NotEqualTo: return(!Btree.Comparer.ByteEqualComparer.isEqual(columnbytes, this.ValueBytes, columnLength)); case Comparer.StartWith: return(Btree.Comparer.MoreComparer.StartWith(columnbytes, this.ValueBytes, this.columnLength)); case Comparer.Contains: return(Btree.Comparer.MoreComparer.Contains(columnbytes, this.ValueBytes, this.columnLength, this.maxColumnLength)); default: return(false); } } }
/// <summary> /// test column value match the condition. /// </summary> /// <param name="columnbytes"></param> /// <returns></returns> public virtual bool isMatch(byte[] columnbytes) { if (columnbytes == null) { return(false); } if (this.DataType == typeof(DateTime)) { var coltime = DateTimeUtcHelper.ToDateTime(columnbytes); return(DateTimeUtcHelper.Compare(compareType, coltime, this.DateTimeValue)); } else { switch (compareType) { case Comparer.EqualTo: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) == 0); case Comparer.GreaterThan: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) > 0); case Comparer.GreaterThanOrEqual: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) >= 0); case Comparer.LessThan: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) < 0); case Comparer.LessThanOrEqual: return(this.byteCompare.Compare(columnbytes, this.ValueBytes) <= 0); case Comparer.NotEqualTo: return(!Btree.Comparer.ByteEqualComparer.isEqual(columnbytes, this.ValueBytes, columnLength)); case Comparer.StartWith: return(Btree.Comparer.MoreComparer.StartWith(columnbytes, this.ValueBytes, this.columnLength)); case Comparer.Contains: return(Btree.Comparer.MoreComparer.Contains(columnbytes, this.ValueBytes, this.columnLength, this.maxColumnLength)); default: return(false); } } }