The .NET SDK supports three categories of data types:
To learn how specific data types are mapped to BSON types in an App Services Schema, refer to Data Model Mapping in the Atlas App Services documentation.
Realm supports the following .NET data types and their nullable counterparts:
bool
byte
short
int
long
float
double
decimal
char
string
byte[]
DateTimeOffset
(note: Realm converts DateTimeOffset
values to UTC before storing in the database and does not store the timezone information. See Issue #1835 for more information.)
Guid
IList<T>
, where T is any of the supported data types (see Lists)
The byte
, char
, short
, int
, and long
types are all stored as 64 bit integer values within Realm.
ObjectId
Decimal128
MongoDB.Bson.ObjectId
is a MongoDB-specific 12-byte unique value, while the built-in .NET type Guid
is a 16-byte universally-unique value. Both types are indexable, and either can be used as a Primary Key.
Realm supports 128-bit decimal values with the Decimal128
Bson type. When defining a decimal type, you can use the Decimal128
Bson type or the .NET decimal
type, even though it is only a 96-bit decimal. The SDK automatically converts between the two, although you risk losing precision or range. The following example shows how to use both the Decimal128
Bson type and the .NET decimal
type:
public class MyClassWithDecimals{ [PrimaryKey] public ObjectId _id { get; } = ObjectId.GenerateNewId(); public decimal VeryPreciseNumber { get; set; } public Decimal128 EvenMorePreciseNumber { get; set; } public Decimal128 AnotherEvenMorePreciseNumber { get; set; } public decimal? MaybeDecimal { get; set; } public Decimal128? MaybeDecimal128 { get; set; } public void DoDecimalStuff() { var myInstance = new MyClassWithDecimals(); realm.Write(() => { myInstance.VeryPreciseNumber = 1.234567890123456789M; myInstance.EvenMorePreciseNumber = Decimal128.Parse("987654321.123456789"); myInstance.EvenMorePreciseNumber = new Decimal128(9.99999); }); }}
Any class that implements RealmObject
or EmbeddedObject
can contain a RealmObject
subclass and/or an Embedded Objects subclass. In addition, Realm supports the following custom types:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4