Kooboo.Commerce.Search.LuceneUtility.ToFieldStringValue C# (CSharp) Méthode

ToFieldStringValue() public static méthode

public static ToFieldStringValue ( object value ) : string
value object
Résultat string
        public static string ToFieldStringValue(object value)
        {
            if (value == null)
            {
                return "<NULL>";
            }

            if (value is DateTime || value is DateTime?)
            {
                return DateTools.DateToString((DateTime)value, DateTools.Resolution.MILLISECOND);
            }

            return value.ToString();
        }

Usage Example

Exemple #1
0
        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));
        }
All Usage Examples Of Kooboo.Commerce.Search.LuceneUtility::ToFieldStringValue