public Filter <TKey, TValue> WhereEqual(string FieldOrPropertyName, Guid Value) { FilterItem item = new FilterItem(); item.Compare = Comparer.EqualTo; item.FieldOrProperty = FieldOrPropertyName; item.FieldType = typeof(Guid); IByteConverter <Guid> x = ObjectContainer.GetConverter <Guid>(); item.Value = x.ToByte(Value); item.Length = 16; this.items.Add(item); return(this); }
/// <summary> /// Filter based on the object primary key. /// </summary> /// <param name="FieldOrPropertyName"></param> /// <param name="comparer"></param> /// <param name="CompareValue"></param> /// <returns></returns> public Filter <TKey, TValue> WhereKey(Comparer comparer, object CompareValue) { FilterItem item = new FilterItem(); item.FieldType = typeof(TKey); item.Length = this.store.StoreSetting.PrimaryKeyLen; item.Compare = comparer; item.FieldOrProperty = this.store.StoreSetting.PrimaryKey; byte[] bytevalue = this.getByteValue(typeof(TKey), CompareValue); if (bytevalue != null) { item.Value = bytevalue; this.items.Add(item); } return(this); }
public Filter <TKey, TValue> Where(string FieldOrPropertyName, Comparer comparer, DateTime CompareValue, DateTimeScope scope) { FilterItem item = new FilterItem(); item.Compare = comparer; item.TimeScope = scope; item.FieldOrProperty = FieldOrPropertyName; item.FieldType = typeof(DateTime); item.Length = 8; IByteConverter <DateTime> x = ObjectContainer.GetConverter <DateTime>(); item.Value = x.ToByte(CompareValue); this.items.Add(item); return(this); }
public Filter <TKey, TValue> Where(string FieldOrPropertyName, Comparer comparer, object CompareValue) { FilterItem item = new FilterItem(); // check to see if there is in the column. IColumn <TValue> column = this.store.GetColumn(FieldOrPropertyName); if (column != null) { item.FieldType = column.DataType; item.Length = column.Length; } else { IIndex <TValue> index = this.store.Indexes.getIndex(FieldOrPropertyName); if (index != null) { item.FieldType = index.keyType; item.Length = index.Length; } else { if (FieldOrPropertyName.IsSameValue(this.store.StoreSetting.PrimaryKey)) { var keytype = Helper.TypeHelper.GetFieldType(this.store.StoreSetting.ValueType, this.store.StoreSetting.PrimaryKey); item.FieldType = keytype; item.Length = this.store.StoreSetting.PrimaryKeyLen; } } } if (item.FieldType == null || item.Length < 1) { throw new Exception("only index or column are allowed in the where condition, consider adding the field into columns in order to search"); } item.Compare = comparer; item.FieldOrProperty = FieldOrPropertyName; byte[] bytevalue = getByteValue(item.FieldType, CompareValue); if (bytevalue != null) { item.Value = bytevalue; //bool and guid, there is not > < =, only equal or not equal. if (item.FieldType == typeof(bool) || item.FieldType == typeof(Guid)) { if (item.Compare != Comparer.EqualTo && item.Compare != Comparer.NotEqualTo) { item.Compare = Comparer.EqualTo; } } //date time, must have specify comare till min, second, millsecond, etc. if (item.FieldType == typeof(DateTime)) { if (item.TimeScope == default(DateTimeScope)) { item.TimeScope = DateTimeScope.day; } } this.items.Add(item); } return(this); }