Table of Contents

Class NpgsqlAggregateDbFunctionsExtensions

Namespace
Microsoft.EntityFrameworkCore
Assembly
Npgsql.EntityFrameworkCore.PostgreSQL.dll

Provides extension methods supporting aggregate function translation for PostgreSQL.

public static class NpgsqlAggregateDbFunctionsExtensions
Inheritance
NpgsqlAggregateDbFunctionsExtensions
Inherited Members

Methods

ArrayAgg<T>(DbFunctions, IEnumerable<T>)

Collects all the input values, including nulls, into a PostgreSQL array. Corresponds to the PostgreSQL array_agg aggregate function.

public static T[] ArrayAgg<T>(this DbFunctions _, IEnumerable<T> input)

Parameters

_ DbFunctions

The DbFunctions instance.

input IEnumerable<T>

The input values to be aggregated into an array.

Returns

T[]

Type Parameters

T
See Also

Average(DbFunctions, IEnumerable<TimeSpan>)

Computes the average (arithmetic mean) of the non-null input intervals. Corresponds to the PostgreSQL avg aggregate function.

public static TimeSpan? Average(this DbFunctions _, IEnumerable<TimeSpan> input)

Parameters

_ DbFunctions

The DbFunctions instance.

input IEnumerable<TimeSpan>

The input values to be computed into an average.

Returns

TimeSpan?
See Also

Correlation(DbFunctions, IEnumerable<(double, double)>)

Computes the correlation coefficient. Corresponds to the PostgreSQL corr function.

public static double? Correlation(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

CovariancePopulation(DbFunctions, IEnumerable<(double, double)>)

Computes the population covariance. Corresponds to the PostgreSQL covar_pop function.

public static double? CovariancePopulation(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

CovarianceSample(DbFunctions, IEnumerable<(double, double)>)

Computes the sample covariance. Corresponds to the PostgreSQL covar_samp function.

public static double? CovarianceSample(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

JsonAgg<T>(DbFunctions, IEnumerable<T>)

Collects all the input values, including nulls, into a json array. Values are converted to JSON as per to_json or to_jsonb. Corresponds to the PostgreSQL json_agg aggregate function.

public static T[] JsonAgg<T>(this DbFunctions _, IEnumerable<T> input)

Parameters

_ DbFunctions

The DbFunctions instance.

input IEnumerable<T>

The input values to be aggregated into a JSON array.

Returns

T[]

Type Parameters

T
See Also

JsonObjectAgg<T1, T2>(DbFunctions, IEnumerable<(T1, T2)>)

Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_json. Values can be null, but not keys. Corresponds to the PostgreSQL json_object_agg aggregate function.

public static string JsonObjectAgg<T1, T2>(this DbFunctions _, IEnumerable<(T1, T2)> keyValuePairs)

Parameters

_ DbFunctions

The DbFunctions instance.

keyValuePairs IEnumerable<(T1, T2)>

An enumerable of key-value pairs to be aggregated into a JSON object.

Returns

string

Type Parameters

T1
T2
See Also

JsonObjectAgg<T1, T2, TReturn>(DbFunctions, IEnumerable<(T1, T2)>)

Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_json. Values can be null, but not keys. Corresponds to the PostgreSQL json_object_agg aggregate function.

public static TReturn JsonObjectAgg<T1, T2, TReturn>(this DbFunctions _, IEnumerable<(T1, T2)> keyValuePairs)

Parameters

_ DbFunctions

The DbFunctions instance.

keyValuePairs IEnumerable<(T1, T2)>

An enumerable of key-value pairs to be aggregated into a JSON object.

Returns

TReturn

Type Parameters

T1
T2
TReturn
See Also

JsonbAgg<T>(DbFunctions, IEnumerable<T>)

Collects all the input values, including nulls, into a jsonb array. Values are converted to JSON as per to_json or to_jsonb. Corresponds to the PostgreSQL jsonb_agg aggregate function.

public static T[] JsonbAgg<T>(this DbFunctions _, IEnumerable<T> input)

Parameters

_ DbFunctions

The DbFunctions instance.

input IEnumerable<T>

The input values to be aggregated into a JSON array.

Returns

T[]

Type Parameters

T
See Also

JsonbObjectAgg<T1, T2>(DbFunctions, IEnumerable<(T1, T2)>)

Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_jsonb. Values can be null, but not keys. Corresponds to the PostgreSQL jsonb_object_agg aggregate function.

public static string JsonbObjectAgg<T1, T2>(this DbFunctions _, IEnumerable<(T1, T2)> keyValuePairs)

Parameters

_ DbFunctions

The DbFunctions instance.

keyValuePairs IEnumerable<(T1, T2)>

An enumerable of key-value pairs to be aggregated into a JSON object.

Returns

string

Type Parameters

T1
T2
See Also

JsonbObjectAgg<T1, T2, TReturn>(DbFunctions, IEnumerable<(T1, T2)>)

Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_jsonb. Values can be null, but not keys. Corresponds to the PostgreSQL jsonb_object_agg aggregate function.

public static TReturn JsonbObjectAgg<T1, T2, TReturn>(this DbFunctions _, IEnumerable<(T1, T2)> keyValuePairs)

Parameters

_ DbFunctions

The DbFunctions instance.

keyValuePairs IEnumerable<(T1, T2)>

An enumerable of key-value pairs to be aggregated into a JSON object.

Returns

TReturn

Type Parameters

T1
T2
TReturn
See Also

RegrAverageX(DbFunctions, IEnumerable<(double, double)>)

Computes the average of the independent variable, sum(X)/N. Corresponds to the PostgreSQL regr_avgx function.

public static double? RegrAverageX(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

RegrAverageY(DbFunctions, IEnumerable<(double, double)>)

Computes the average of the dependent variable, sum(Y)/N. Corresponds to the PostgreSQL regr_avgy function.

public static double? RegrAverageY(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

RegrCount(DbFunctions, IEnumerable<(double, double)>)

Computes the number of rows in which both inputs are non-null. Corresponds to the PostgreSQL regr_count function.

public static long? RegrCount(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

long?

RegrIntercept(DbFunctions, IEnumerable<(double, double)>)

Computes the y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs. Corresponds to the PostgreSQL regr_intercept function.

public static double? RegrIntercept(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

RegrR2(DbFunctions, IEnumerable<(double, double)>)

Computes the square of the correlation coefficient. Corresponds to the PostgreSQL regr_r2 function.

public static double? RegrR2(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

RegrSXX(DbFunctions, IEnumerable<(double, double)>)

Computes the “sum of squares” of the independent variable, sum(X^2) - sum(X)^2/N. Corresponds to the PostgreSQL regr_sxx function.

public static double? RegrSXX(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

RegrSXY(DbFunctions, IEnumerable<(double, double)>)

Computes the “sum of products” of independent times dependent variables, sum(X*Y) - sum(X) * sum(Y)/N. Corresponds to the PostgreSQL regr_sxy function.

public static double? RegrSXY(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

RegrSlope(DbFunctions, IEnumerable<(double, double)>)

Computes the slope of the least-squares-fit linear equation determined by the (X, Y) pairs. Corresponds to the PostgreSQL regr_slope function.

public static double? RegrSlope(this DbFunctions _, IEnumerable<(double, double)> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<(double, double)>

The values.

Returns

double?

StandardDeviationPopulation(DbFunctions, IEnumerable<byte>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<byte> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<byte>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationPopulation(DbFunctions, IEnumerable<decimal>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<decimal> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<decimal>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationPopulation(DbFunctions, IEnumerable<double>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<double> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<double>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationPopulation(DbFunctions, IEnumerable<short>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<short> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<short>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationPopulation(DbFunctions, IEnumerable<int>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<int> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<int>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationPopulation(DbFunctions, IEnumerable<long>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<long> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<long>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationPopulation(DbFunctions, IEnumerable<float>)

Returns the population standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_pop function.

public static double? StandardDeviationPopulation(this DbFunctions _, IEnumerable<float> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<float>

The values.

Returns

double?

The computed population standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<byte>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<byte> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<byte>

The values.

Returns

double?

The computed sample standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<decimal>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<decimal> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<decimal>

The values.

Returns

double?

The computed sample standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<double>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<double> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<double>

The values.

Returns

double?

The computed sample standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<short>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<short> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<short>

The values.

Returns

double?

The computed sample standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<int>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<int> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<int>

The values.

Returns

double?

The computed sample standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<long>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<long> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<long>

The values.

Returns

double?

The computed sample standard deviation.

StandardDeviationSample(DbFunctions, IEnumerable<float>)

Returns the sample standard deviation of all values in the specified expression. Corresponds to the PostgreSQL stddev_samp function.

public static double? StandardDeviationSample(this DbFunctions _, IEnumerable<float> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<float>

The values.

Returns

double?

The computed sample standard deviation.

Sum(DbFunctions, IEnumerable<TimeSpan>)

Computes the sum of the non-null input intervals. Corresponds to the PostgreSQL sum aggregate function.

public static TimeSpan? Sum(this DbFunctions _, IEnumerable<TimeSpan> input)

Parameters

_ DbFunctions

The DbFunctions instance.

input IEnumerable<TimeSpan>

The input values to be summed.

Returns

TimeSpan?
See Also

VariancePopulation(DbFunctions, IEnumerable<byte>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<byte> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<byte>

The values.

Returns

double?

The computed population variance.

VariancePopulation(DbFunctions, IEnumerable<decimal>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<decimal> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<decimal>

The values.

Returns

double?

The computed population variance.

VariancePopulation(DbFunctions, IEnumerable<double>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<double> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<double>

The values.

Returns

double?

The computed population variance.

VariancePopulation(DbFunctions, IEnumerable<short>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<short> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<short>

The values.

Returns

double?

The computed population variance.

VariancePopulation(DbFunctions, IEnumerable<int>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<int> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<int>

The values.

Returns

double?

The computed population variance.

VariancePopulation(DbFunctions, IEnumerable<long>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<long> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<long>

The values.

Returns

double?

The computed population variance.

VariancePopulation(DbFunctions, IEnumerable<float>)

Returns the population variance of all values in the specified expression. Corresponds to the PostgreSQL var_pop function.

public static double? VariancePopulation(this DbFunctions _, IEnumerable<float> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<float>

The values.

Returns

double?

The computed population variance.

VarianceSample(DbFunctions, IEnumerable<byte>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<byte> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<byte>

The values.

Returns

double?

The computed sample variance.

VarianceSample(DbFunctions, IEnumerable<decimal>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<decimal> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<decimal>

The values.

Returns

double?

The computed sample variance.

VarianceSample(DbFunctions, IEnumerable<double>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<double> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<double>

The values.

Returns

double?

The computed sample variance.

VarianceSample(DbFunctions, IEnumerable<short>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<short> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<short>

The values.

Returns

double?

The computed sample variance.

VarianceSample(DbFunctions, IEnumerable<int>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<int> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<int>

The values.

Returns

double?

The computed sample variance.

VarianceSample(DbFunctions, IEnumerable<long>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<long> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<long>

The values.

Returns

double?

The computed sample variance.

VarianceSample(DbFunctions, IEnumerable<float>)

Returns the sample variance of all values in the specified expression. Corresponds to the PostgreSQL var_samp function.

public static double? VarianceSample(this DbFunctions _, IEnumerable<float> values)

Parameters

_ DbFunctions

The DbFunctions instance.

values IEnumerable<float>

The values.

Returns

double?

The computed sample variance.