Exemple #1
0
        /// <inheritdoc />
        public void OrderByDistance(DynamicSpatialField field, double latitude, double longitude)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            OrderByDistance($"'{field.ToField(EnsureValidFieldName)}'", latitude, longitude);
        }
Exemple #2
0
        /// <inheritdoc />
        public void Spatial(DynamicSpatialField dynamicField, SpatialCriteria criteria)
        {
            var tokens = GetCurrentWhereTokens();

            AppendOperatorIfNeeded(tokens);
            NegateIfNeeded(tokens, null);

            tokens.AddLast(criteria.ToQueryToken(dynamicField.ToField(EnsureValidFieldName), AddQueryParameter));
        }
Exemple #3
0
        /// <inheritdoc />
        public void OrderByDistanceDescending(DynamicSpatialField field, string shapeWkt)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            OrderByDistanceDescending($"'{field.ToField(EnsureValidFieldName)}'", shapeWkt);
        }
        /// <inheritdoc />
        public void OrderByDistanceDescending(DynamicSpatialField field, double latitude, double longitude)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            AssertIsDynamicQuery(field, nameof(OrderByDistanceDescending));

            OrderByDistanceDescending($"'{field.ToField(EnsureValidFieldName)}'", latitude, longitude);
        }
        /// <inheritdoc />
        public void OrderByDistance(DynamicSpatialField field, string shapeWkt)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            AssertIsDynamicQuery(field, nameof(OrderByDistance));

            OrderByDistance($"'{field.ToField(EnsureValidFieldName)}'", shapeWkt);
        }
 private void AssertIsDynamicQuery(DynamicSpatialField dynamicField, string methodName)
 {
     if (FromToken.IsDynamic == false)
     {
         throw new InvalidOperationException($"Cannot execute query method '{methodName}'. Field '{dynamicField.ToField(EnsureValidFieldName)}' cannot be used when static index '{FromToken.IndexName}' is queried. Dynamic spatial fields can only be used with dynamic queries, for static index queries please use valid spatial fields defined in index definition.");
     }
 }