Class ApplyFunctions
Functions to use within apply expressions. Minimal implementations provided for sanity checks, but this should be used primarily within expressions.
Inheritance
Inherited Members
Namespace: Redis.OM.Aggregation.AggregationPredicates
Assembly: Redis.OM.dll
Syntax
public static class ApplyFunctions
Methods
| Improve this Doc View SourceDay(Int64)
Rounds the timestamp to midnight of the current day.
Declaration
public static long Day(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | the timestamp rounded to midnight. |
DayOfMonth(Int64)
Gets the day of the month from the timestamp.
Declaration
public static long DayOfMonth(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | The day of the month. |
DayOfWeek(Int64)
get's the day of the week from the timestamp.
Declaration
public static long DayOfWeek(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | the day of the week Sunday=0. |
DayOfYear(Int64)
Gets the day of the year from the timestamp.
Declaration
public static long DayOfYear(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | The day of the year. |
Exists(Object)
checks if the field exists on the object in redis.
Declaration
public static bool Exists(object field)
Parameters
Type | Name | Description |
---|---|---|
System.Object | field | the field to check. |
Returns
Type | Description |
---|---|
System.Boolean | whether the field exists or not. |
FormatTimestamp(Int64)
Formats the unix timestamp into a string timestamp.
Declaration
public static string FormatTimestamp(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.String | a formatted timestamp of %FT%TZ. |
FormatTimestamp(Int64, String)
Formats the unix timestamp into a string timestamp.
Declaration
public static string FormatTimestamp(long timestamp, string format)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
System.String | format | The format to use strftime. |
Returns
Type | Description |
---|---|
System.String | a formatted timestamp of %FT%TZ. |
GeoDistance(GeoLoc, GeoLoc)
calculates the distance between two points in meters.
Declaration
public static double GeoDistance(GeoLoc loc1, GeoLoc loc2)
Parameters
Type | Name | Description |
---|---|---|
GeoLoc | loc1 | first location. |
GeoLoc | loc2 | second location. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
GeoDistance(GeoLoc, Double, Double)
calculates the distance between two points in meters.
Declaration
public static double GeoDistance(GeoLoc loc1, double lon2, double lat2)
Parameters
Type | Name | Description |
---|---|---|
GeoLoc | loc1 | first location. |
System.Double | lon2 | Second location's longitude. |
System.Double | lat2 | Second location's latitude. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
GeoDistance(GeoLoc, String)
calculates the distance between two points in meters.
Declaration
public static double GeoDistance(GeoLoc loc1, string loc2Str)
Parameters
Type | Name | Description |
---|---|---|
GeoLoc | loc1 | first location. |
System.String | loc2Str | second location. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
GeoDistance(Double, Double, GeoLoc)
Calculates the distance between two points in meters.
Declaration
public static double GeoDistance(double lon1, double lat1, GeoLoc loc2)
Parameters
Type | Name | Description |
---|---|---|
System.Double | lon1 | first location's longitude. |
System.Double | lat1 | first location's latitude. |
GeoLoc | loc2 | second location. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
GeoDistance(Double, Double, Double, Double)
Calculates the distance between two points. Minimal implementation taken from Stackoverflow. https://stackoverflow.com/a/51839058/7299345.
Declaration
public static double GeoDistance(double longitude, double latitude, double otherLongitude, double otherLatitude)
Parameters
Type | Name | Description |
---|---|---|
System.Double | longitude | first location longitude. |
System.Double | latitude | first location latitude. |
System.Double | otherLongitude | second location longitude. |
System.Double | otherLatitude | second location's latitude. |
Returns
Type | Description |
---|---|
System.Double | distance in meters. |
GeoDistance(Double, Double, String)
Calculates the distance between two points in meters.
Declaration
public static double GeoDistance(double lon1, double lat1, string loc2Str)
Parameters
Type | Name | Description |
---|---|---|
System.Double | lon1 | first location's longitude. |
System.Double | lat1 | first location's latitude. |
System.String | loc2Str | second location. |
Returns
Type | Description |
---|---|
System.Double | distance in meters. |
GeoDistance(String, GeoLoc)
calculates the distance between two points in meters.
Declaration
public static double GeoDistance(string loc1Str, GeoLoc loc2)
Parameters
Type | Name | Description |
---|---|---|
System.String | loc1Str | First location. |
GeoLoc | loc2 | Second location. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
GeoDistance(String, Double, Double)
calculates the distance between two points in meters.
Declaration
public static double GeoDistance(string loc1Str, double lon2, double lat2)
Parameters
Type | Name | Description |
---|---|---|
System.String | loc1Str | First location. |
System.Double | lon2 | Second location longitude. |
System.Double | lat2 | Second location latitude. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
GeoDistance(String, String)
calculates the distance between two points in meters.
Declaration
public static double GeoDistance(string loc1Str, string loc2Str)
Parameters
Type | Name | Description |
---|---|---|
System.String | loc1Str | First location. |
System.String | loc2Str | Second location. |
Returns
Type | Description |
---|---|
System.Double | the distance in meters. |
Hour(Int64)
Rounds the timestamp to the beginning of the current hour.
Declaration
public static long Hour(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | the timestamp rounded to the current hour. |
Minute(Int64)
Rounds the timestamp to the beginning of the current minute.
Declaration
public static long Minute(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | the timestamp rounded to the current minute. |
Month(Int64)
Rounds the timestamp to the beginning of the current month.
Declaration
public static long Month(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | The timestamp rounded to the beginning of the current month. |
MonthOfYear(Int64)
Gets the month from the timestamp.
Declaration
public static long MonthOfYear(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | the month. |
ParseTime(String)
parses a unix timestamp from the provided string.
Declaration
public static long ParseTime(string timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.String | timestamp | the timestamp in %FT%TZ format. |
Returns
Type | Description |
---|---|
System.Int64 | the unix timestamp. |
ParseTime(String, String)
Formats the unix timestamp into a string timestamp.
Declaration
public static long ParseTime(string timestamp, string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | timestamp | the timestamp. |
System.String | format | The format to use strftime. |
Returns
Type | Description |
---|---|
System.Int64 | a formatted timestamp of %FT%TZ. |
Year(Int64)
Gets the year from the timestamp.
Declaration
public static long Year(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | the timestamp. |
Returns
Type | Description |
---|---|
System.Int64 | the year. |