Class QueryMethods
Provides methods that get translated into native Realm queries when using LINQ.
Namespace: Realms
Assembly: Realm.dll
Syntax
public static class QueryMethods
Remarks
These methods don't have implementation and are only usable in a LINQ query performed on a Realm query result - e.g. the IQueryable returned by All<T>().
Methods
| Edit this page View SourceContains(string?, string, StringComparison)
Returns a value indicating whether a specified substring occurs within this string.
Declaration
public static bool Contains(string? str, string value, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
string | str | The original string. |
string | value | The string to seek. |
StringComparison | comparisonType | One of the enumeration values that determines how this string and value are compared. |
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
ArgumentException | Thrown when |
FullTextSearch(string?, string)
Performs a 'simple term' Full-Text search on a string property.
Declaration
public static bool FullTextSearch(string? str, string terms)
Parameters
Type | Name | Description |
---|---|---|
string | str | The string to compare against the terms. |
string | terms | The terms to look for in |
Returns
Type | Description |
---|---|
bool |
|
Remarks
When this method is used outside of a Realm query, a NotSupportedException will be thrown.
Examples
var matches = realm.All<Book>().Where(b => b.Summary.FullTextSearch("fantasy novel"));
|
Edit this page
View Source
GeoWithin(IEmbeddedObject?, GeoShapeBase)
Checks whether geoShape
contains the point represented by an embedded object.
Declaration
public static bool GeoWithin(IEmbeddedObject? point, GeoShapeBase geoShape)
Parameters
Type | Name | Description |
---|---|---|
IEmbeddedObject | point | An embedded object that has the shape of a GeoJson point. It must have at least two fields - |
GeoShapeBase | geoShape | One of GeoBox, GeoCircle, or GeoPolygon representing the shape that |
Returns
Type | Description |
---|---|
bool |
|
Examples
An example embedded object that can be used in geospatial queries is:
public partial class MyGeoPoint : IEmbeddedObject
{
[MapTo("coordinates")]
private IList<double> Coordinates { get; } = null!;
[MapTo("type")]
private string Type { get; set; } = "Point";
public double Latitude => Coordinates.Count > 1 ? Coordinates[1] : throw new Exception($"Invalid coordinate array. Expected at least 2 elements, but got: {Coordinates.Count}");
public double Longitude => Coordinates.Count > 1 ? Coordinates[0] : throw new Exception($"Invalid coordinate array. Expected at least 2 elements, but got: {Coordinates.Count}");
public MyGeoPoint(double latitude, double longitude)
{
Coordinates.Add(longitude);
Coordinates.Add(latitude);
}
}
|
Edit this page
View Source
Like(string?, string, bool)
Performs a 'like' comparison between the specified string and pattern.
Declaration
public static bool Like(string? str, string pattern, bool caseSensitive = true)
Parameters
Type | Name | Description |
---|---|---|
string | str | The string to compare against the pattern. |
string | pattern | The pattern to compare against. |
bool | caseSensitive | If set to |
Returns
Type | Description |
---|---|
bool |
|
Remarks
?
and are allowed where
?
matches a single character and matches zero or
more characters, such that
?bc*
matches abcde
and bbc
, but does not match bcd
.