public IndexQuery WhereBetween(string field, object fromValue, object toValue, bool fromInclusive, bool toInclusive)
{
if (fromValue == null && toValue == null)
{
return(this);
}
var isNumericField = false;
var property = ModelType.GetProperty(field, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
// property might be null because it might be custom fields
if (property != null)
{
var fieldAttr = property.GetCustomAttribute <FieldAttribute>();
isNumericField = fieldAttr != null && fieldAttr.Numeric;
}
Query query = null;
if (isNumericField)
{
query = CreateNumericRangeQuery(field, property.PropertyType, fromValue, toValue, fromInclusive, toInclusive);
}
else
{
query = new TermRangeQuery(field, LuceneUtility.ToFieldStringValue(fromValue), LuceneUtility.ToFieldStringValue(toValue), fromInclusive, toInclusive);
}
return(And(query));
}