Пример #1
0
 /// <summary>
 /// The metaphone function converts a string to its Metaphone code.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>metaphone(text, maximumOutputLength)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static string FuzzyStringMatchMetaphone(this DbFunctions _, string text, int maximumOutputLength)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchMetaphone)));
Пример #2
0
 /// <summary>
 ///     A random double number generator which generates a number between 0 and 1, exclusive.
 /// </summary>
 /// <remarks>
 ///     This DbFunction method has no in-memory implementation and will throw if the query switches to client-evaluation.
 ///     This can happen if the query contains one or more expressions that could not be translated to the store.
 /// </remarks>
 /// <param name="_"> The <see cref="DbFunctions" /> instance. </param>
 /// <returns> A random double number between 0 and 1, exclusive. </returns>
 public static double Random(this DbFunctions _)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Random)));
 /// <summary>
 /// Returns the minimum distance between the origin geometry and another geometry g.
 /// </summary>
 /// <param name="geometry">The origin geometry.</param>
 /// <param name="anotherGeometry">The geometry from which to compute the distance.</param>
 /// <param name="useSpheroid">Whether to use sphere or spheroid distance measurement.</param>
 /// <returns>The distance between the geometries.</returns>
 /// <exception cref="ArgumentException">If g is null</exception>
 public static double Distance(this DbFunctions _, Geometry geometry, Geometry anotherGeometry, bool useSpheroid)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Distance)));
Пример #4
0
 /// <summary>
 ///    Counts the number of month boundaries crossed between the startDate and endDate.
 ///    Corresponds to Oracle TRUNC(MONTHS_BETWEEN(endDate, startDate))
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of month boundaries crossed between the dates.</returns>
 public static int DateDiffMonth(
     [CanBeNull] this DbFunctions _,
     DateTime startDate,
     DateTime endDate)
 => 12 * (endDate.Year - startDate.Year) + endDate.Month - startDate.Month;
Пример #5
0
 /// <summary>
 ///     <para>
 ///         An implementation of the SQL <c>LIKE</c> operation. On relational databases this is usually directly
 ///         translated to SQL.
 ///     </para>
 ///     <para>
 ///         Note that the semantics of the comparison will depend on the database configuration.
 ///         In particular, it may be either case-sensitive or case-insensitive.
 ///     </para>
 /// </summary>
 /// <remarks>
 ///     This DbFunction method has no in-memory implementation and will throw if the query switches to client-evaluation.
 ///     This can happen if the query contains one or more expressions that could not be translated to the store.
 /// </remarks>
 /// <param name="_">The <see cref="DbFunctions" /> instance.</param>
 /// <param name="matchExpression">The string that is to be matched.</param>
 /// <param name="pattern">The pattern which may involve wildcards <c>%,_,[,],^</c>.</param>
 /// <returns><see langword="true" /> if there is a match.</returns>
 public static bool Like(
     [CanBeNull] this DbFunctions _,
     [CanBeNull] string matchExpression,
     [CanBeNull] string pattern)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Like)));
 /// <summary>
 ///     Returns the mimimum spherical distance between Point or MultiPoint arguments on a sphere in meters,
 ///     by using the specified algorithm.
 ///     It is assumed that `g1` and `g2` are associated with an SRID of `4326`.
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="g1">First geometry argument.</param>
 /// <param name="g2">Second geometry argument.</param>
 /// <param name="algorithm">The algorithm to use. Must be directly supplied as a constant.</param>
 /// <returns>Distance betweeen g1 and g2.</returns>
 public static double SpatialDistanceSphere(
     [CanBeNull] this DbFunctions _,
     Geometry g1,
     Geometry g2,
     SpatialDistanceAlgorithm algorithm)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(SpatialDistanceSphere)));
Пример #7
0
 /// <summary>
 ///    Counts the number of year boundaries crossed between the startDate and endDate.
 ///    Corresponds to Oracle EXTRACT(YEAR FROM endDate) - EXTRACT(YEAR FROM startDate)
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of year boundaries crossed between the dates.</returns>
 public static int DateDiffYear(
     [CanBeNull] this DbFunctions _,
     DateTime startDate,
     DateTime endDate)
 => endDate.Year - startDate.Year;
 /// <summary>
 /// The metaphone function converts a string to its Metaphone code.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>metaphone(text, maximumOutputLength)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static string FuzzyStringMatchMetaphone(this DbFunctions _, string text, int maximumOutputLength) =>
 throw new NotSupportedException();
 /// <summary>
 /// The dmetaphone function converts a string to its primary Double Metaphone code.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>dmetaphone(text)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static string FuzzyStringMatchDoubleMetaphone(this DbFunctions _, string text) =>
 throw new NotSupportedException();
 /// <summary>
 /// Returns the Levenshtein distance between two strings.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>levenshtein(source, target)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source, string target) =>
 throw new NotSupportedException();
 /// <summary>
 /// levenshtein_less_equal is an accelerated version of the Levenshtein function for use when only small distances are of interest.
 /// If the actual distance is less than or equal to maximum distance, then levenshtein_less_equal returns the correct distance;
 /// otherwise it returns some value greater than maximum distance. If maximum distance is negative then the behavior is the same as levenshtein.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>levenshtein_less_equal(source, target, insertionCost, deletionCost, substitutionCost, maximumDistance)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, string source, string target, int insertionCost, int deletionCost, int substitutionCost, int maximumDistance) =>
 throw new NotSupportedException();
 /// <summary>
 /// The difference function converts two strings to their Soundex codes and
 /// then returns the number of matching code positions. Since Soundex codes
 /// have four characters, the result ranges from zero to four, with zero being
 /// no match and four being an exact match.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>difference(source, target)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static int FuzzyStringMatchDifference(this DbFunctions _, string source, string target) =>
 throw new NotSupportedException();
 /// <summary>
 /// The soundex function converts a string to its Soundex code.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>soundex(text)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static string FuzzyStringMatchSoundex(this DbFunctions _, string text) =>
 throw new NotSupportedException();
Пример #14
0
 /// <summary>
 /// The dmetaphone function converts a string to its primary Double Metaphone code.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>dmetaphone(text)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static string FuzzyStringMatchDoubleMetaphone(this DbFunctions _, string text)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchDoubleMetaphone)));
Пример #15
0
 /// <summary>
 ///     Counts the number of month boundaries crossed between the startDate and endDate.
 ///     Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate).
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of month boundaries crossed between the dates.</returns>
 public static int?DateDiffMonth(
     [CanBeNull] this DbFunctions _,
     DateTime?startDate,
     DateTime?endDate)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMonth)));
 /// <summary>
 /// Convert <paramref name="lexemes" /> to a tsvector.
 /// </summary>
 /// <remarks>
 /// https://www.postgresql.org/docs/current/static/functions-textsearch.html
 /// </remarks>
 public static NpgsqlTsVector ArrayToTsVector(this DbFunctions _, string[] lexemes) =>
 throw new NotSupportedException();
 /// <summary>
 ///     Returns the distance between g1 and g2, measured in the length unit of the spatial reference system
 ///     (SRS) of the geometry arguments.
 ///     For MySQL 8, this is equivalent of calling ST_Distance() when using an SRID of `0`.
 ///     For MySQL &lt; 8 and MariaDB, this is equivalent of calling ST_Distance() with any SRID.
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="g1">First geometry argument.</param>
 /// <param name="g2">Second geometry argument.</param>
 /// <returns>Distance betweeen g1 and g2.</returns>
 public static double SpatialDistancePlanar(
     [CanBeNull] this DbFunctions _,
     Geometry g1,
     Geometry g2)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(SpatialDistancePlanar)));
 /// <summary>
 /// Reduce <paramref name="document" /> to tsvector using the text search configuration specified
 /// by <paramref name="config" />.
 /// </summary>
 /// <remarks>
 /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-DOCUMENTS
 /// </remarks>
 public static NpgsqlTsVector ToTsVector(this DbFunctions _, string config, string document) =>
 throw new NotSupportedException();
Пример #19
0
 /// <summary>
 ///    Counts the number of day boundaries crossed between the startDate and endDate.
 ///    Corresponds to Oracle EXTRACT(DAY FROM endDate - startDate)
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of day boundaries crossed between the dates.</returns>
 public static int DateDiffDay(
     [CanBeNull] this DbFunctions _,
     DateTime startDate,
     DateTime endDate)
 => (endDate.Date - startDate.Date).Days;
 /// <summary>
 /// Normalize words in <paramref name="query" /> and convert to tsquery using the text search
 /// configuration specified by <paramref name="config" />. If your input contains punctuation
 /// that should not be treated as text search operators, use
 /// <see cref="PlainToTsQuery(DbFunctions, string, string)" /> instead.
 /// </summary>
 /// <remarks>
 /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
 /// </remarks>
 public static NpgsqlTsQuery ToTsQuery(this DbFunctions _, string config, string query) =>
 throw new NotSupportedException();
Пример #21
0
 /// <summary>
 ///    Counts the number of year boundaries crossed between the startDate and endDate.
 ///    Corresponds to Oracle EXTRACT(YEAR FROM endDate) - EXTRACT(YEAR FROM startDate)
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of year boundaries crossed between the dates.</returns>
 public static int DateDiffYear(
     [CanBeNull] this DbFunctions _,
     DateTimeOffset startDate,
     DateTimeOffset endDate)
 => DateDiffYear(_, startDate.UtcDateTime, endDate.UtcDateTime);
Пример #22
0
 /// <summary>
 ///     Counts the number of microsecond boundaries crossed between the startDate and endDate.
 ///     Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate).
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of microsecond boundaries crossed between the dates.</returns>
 public static int?DateDiffMicrosecond(
     [CanBeNull] this DbFunctions _,
     DateTimeOffset?startDate,
     DateTimeOffset?endDate)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMicrosecond)));
 /// <summary>
 ///     <para>
 ///         Explicitly specifies a collation to be used in a LINQ query. Can be used to generate fragments such as
 ///         <code>WHERE customer.name COLLATE 'de_DE' = 'John Doe'</code>.
 ///     </para>
 ///     <para>
 ///         The available collations and their names vary across databases, consult your database's documentation for more
 ///         information.
 ///     </para>
 /// </summary>
 /// <typeparam name="TProperty"> The type of the operand on which the collation is being specified. </typeparam>
 /// <param name="_"> The DbFunctions instance. </param>
 /// <param name="operand"> The operand to which to apply the collation. </param>
 /// <param name="collation"> The name of the collation. </param>
 public static TProperty Collate <TProperty>(
     [NotNull] this DbFunctions _,
     [NotNull] TProperty operand,
     [NotNull][NotParameterized] string collation)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Collate)));
Пример #24
0
 /// <summary>
 ///     <para>
 ///         An implementation of the SQL MATCH operation for Full Text search.
 ///     </para>
 ///     <para>
 ///         The semantics of the comparison will depend on the database configuration.
 ///         In particular, it may be either case-sensitive or
 ///         case-insensitive.
 ///     </para>
 ///     <para>
 ///         Should be directly translated to SQL.
 ///         This function can't be evaluated on the client.
 ///     </para>
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="matchExpression">The property of entity that is to be matched.</param>
 /// <param name="pattern">The pattern against which Full Text search is performed</param>
 /// <param name="searchMode">Mode in which search is performed</param>
 /// <returns>true if there is a match.</returns>
 /// <exception cref="InvalidOperationException">Throws when query switched to client-evaluation.</exception>
 public static bool Match <T>(
     [CanBeNull] this DbFunctions _,
     [CanBeNull] T matchExpression,
     [CanBeNull] string pattern,
     MySqlMatchSearchMode searchMode)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Match)));
Пример #25
0
 /// <summary>
 ///     <para>
 ///         An implementation of the SQL LIKE operation. On relational databases this is usually directly
 ///         translated to SQL.
 ///     </para>
 ///     <para>
 ///         Note that the semantics of the comparison will depend on the database configuration.
 ///         In particular, it may be either case-sensitive or case-insensitive.
 ///     </para>
 /// </summary>
 /// <remarks>
 ///     This DbFunction method has no in-memory implementation and will throw if the query switches to client-evaluation.
 ///     This can happen if the query contains one or more expressions that could not be translated to the store.
 /// </remarks>
 /// <param name="_">The <see cref="DbFunctions" /> instance.</param>
 /// <param name="matchExpression">The string that is to be matched.</param>
 /// <param name="pattern">The pattern which may involve wildcards %,_,[,],^.</param>
 /// <param name="escapeCharacter">
 ///     The escape character (as a single character string) to use in front of %,_,[,],^
 ///     if they are not used as wildcards.
 /// </param>
 /// <returns><see langword="true" /> if there is a match.</returns>
 public static bool Like(
     this DbFunctions _,
     string matchExpression,
     string pattern,
     string escapeCharacter)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Like)));
Пример #26
0
 /// <summary>
 /// For a string argument `value`, Unhex() interprets each pair of characters in the argument as a hexadecimal
 /// number and converts it to the byte represented by the number.
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="value">The hexadecimal string to convert to a character string.</param>
 /// <returns>The string or `null`.</returns>
 public static string Unhex(
     [CanBeNull] this DbFunctions _,
     [CanBeNull] string value)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Hex)));
 /// <summary>
 /// Returns a new geometry with its coordinates transformed to a different spatial reference system.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>ST_Transform(geometry, srid)</c>.
 ///
 /// See https://postgis.net/docs/ST_Transform.html.
 /// </remarks>
 public static TGeometry Transform <TGeometry>(this DbFunctions _, TGeometry geometry, int srid)
     where TGeometry : Geometry
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Transform)));
Пример #28
0
 /// <summary>
 ///     Counts the number of year boundaries crossed between the startDate and endDate.
 ///     Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate).
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="startDate">Starting date for the calculation.</param>
 /// <param name="endDate">Ending date for the calculation.</param>
 /// <returns>Number of year boundaries crossed between the dates.</returns>
 public static int DateDiffYear(
     [CanBeNull] this DbFunctions _,
     DateTimeOffset startDate,
     DateTimeOffset endDate)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffYear)));
 /// <summary>
 ///     An implementation of the PostgreSQL ILIKE operation, which is an insensitive LIKE.
 /// </summary>
 /// <param name="_">The DbFunctions instance.</param>
 /// <param name="matchExpression">The string that is to be matched.</param>
 /// <param name="pattern">The pattern which may involve wildcards %,_,[,],^.</param>
 /// <param name="escapeCharacter">
 ///     The escape character (as a single character string) to use in front of %,_,[,],^
 ///     if they are not used as wildcards.
 /// </param>
 /// <returns>true if there is a match.</returns>
 public static bool ILike(
     [CanBeNull] this DbFunctions _,
     [CanBeNull] string matchExpression,
     [CanBeNull] string pattern,
     [CanBeNull] string escapeCharacter)
 => LikeCore(matchExpression, pattern, escapeCharacter);
Пример #30
0
 /// <summary>
 /// levenshtein_less_equal is an accelerated version of the Levenshtein function for use when only small distances are of interest.
 /// If the actual distance is less than or equal to maximum distance, then levenshtein_less_equal returns the correct distance;
 /// otherwise it returns some value greater than maximum distance. If maximum distance is negative then the behavior is the same as levenshtein.
 /// </summary>
 /// <remarks>
 /// The method call is translated to <c>levenshtein_less_equal(source, target, insertionCost, deletionCost, substitutionCost, maximumDistance)</c>.
 ///
 /// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
 /// </remarks>
 public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, string source, string target, int insertionCost, int deletionCost, int substitutionCost, int maximumDistance)
 => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchLevenshteinLessEqual)));