Realm 12.3.0
See the version list below for details.
dotnet add package Realm --version 12.3.0
NuGet\Install-Package Realm -Version 12.3.0
<PackageReference Include="Realm" Version="12.3.0" />
paket add Realm --version 12.3.0
#r "nuget: Realm, 12.3.0"
// Install Realm as a Cake Addin #addin nuget:?package=Realm&version=12.3.0 // Install Realm as a Cake Tool #tool nuget:?package=Realm&version=12.3.0
<picture> <source srcset="./media/logo-dark.svg" media="(prefers-color-scheme: dark)" alt="realm by MongoDB"> <img src="./media/logo.svg" alt="realm by MongoDB"> </picture>
Realm is a mobile database that runs directly on phones, tablets or wearables. It supports all major mobile and desktop operating systems, such as iOS, Android, UWP, macOS, Linux, and Windows. For a full list of supported platforms and their versions, check out the Platform and Framework Compatibility section in the documentation.
Features
- Mobile-first: Realm is the first database built from the ground up to run directly inside phones, tablets, and wearables.
- Simple: Data is directly exposed as objects and queryable by code, removing the need for ORM's riddled with performance & maintenance issues. Plus, we've worked hard to keep our API down to just a few common classes: most of our users pick it up intuitively, getting simple apps up & running in minutes.
- Modern: Realm supports relationships, generics, vectorization and modern C# idioms.
- Fast: Realm is faster than even raw SQLite on common operations while maintaining an extremely rich feature set.
- Device Sync: Makes it simple to keep data in sync across users, devices, and your backend in real-time. Get started for free with a template application and create the cloud backend.
Getting Started
Model definition
Define a persistable model by inheriting from IRealmObject
. The Realm source generator will generate an implementation for most of the functionality, so you only need to specify the properties you want to persist:
public partial class Person : IRealmObject
{
[PrimaryKey]
public ObjectId Id { get; private set; } = ObjectId.GenerateNewId();
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTimeOffset Birthday { get; set; }
// You can define constructors as usual
public Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
}
Open a Realm file
Open a Realm instance by calling Realm.GetInstance
:
// You can provide a relative or an absolute path to the Realm file or let
// Realm use the default one.
var realm = Realm.GetInstance("people.realm");
CRUD operations
Add, read, update, and remove objects by calling the corresponding API on the Realm
instance:
// Always mutate the Realm instance in a write transaction
realm.Write(() =>
{
realm.Add(new Person("John", "Smith"));
});
var peopleWithJ = realm.All<Person>().Where(p => p.FirstName.StartsWith("J"));
// All Realm collections and objects are reactive and implement INotifyCollectionChanged/INotifyPropertyChanged
peopleWithJ.AsRealmCollection().CollectionChanged += (s, e) =>
{
// React to notifications
};
For more examples, see the detailed instructions in our User Guide to add Realm to your solution.
Documentation
The documentation can be found at mongodb.com/docs/atlas/device-sdks/sdk/dotnet/. The API reference is located at mongodb.com/docs/realm-sdks/dotnet/latest/.
Getting Help
- Need help with your code?: Look for previous questions on the #realm tag — or ask a new question. You can also check out our Community Forum where general questions about how to do something can be discussed.
- Have a bug to report? Open an issue. If possible, include the version of Realm, a full log, the Realm file, and a project that shows the issue.
- Have a feature request? Open an issue. Tell us what the feature should do, and why you want the feature.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios is compatible. |
Xamarin.Mac | xamarinmac is compatible. |
Xamarin.TVOS | xamarintvos is compatible. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Fody (>= 6.8.1)
- Microsoft.CSharp (>= 4.5.0)
- MongoDB.Bson (>= 2.21.0)
- Realm.PlatformHelpers (>= 12.3.0)
- Remotion.Linq (>= 2.2.0)
- System.Buffers (>= 4.5.1)
- System.Dynamic.Runtime (>= 4.3.0)
- System.Memory (>= 4.5.5)
- System.Net.Security (>= 4.3.2)
- System.Net.WebSockets.Client (>= 4.3.2)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- System.Threading.Channels (>= 6.0.0)
-
net6.0
- Fody (>= 6.8.1)
- Microsoft.CSharp (>= 4.5.0)
- MongoDB.Bson (>= 2.21.0)
- Realm.PlatformHelpers (>= 12.3.0)
- Remotion.Linq (>= 2.2.0)
- System.Buffers (>= 4.5.1)
- System.Dynamic.Runtime (>= 4.3.0)
- System.Memory (>= 4.5.5)
- System.Net.Security (>= 4.3.2)
- System.Net.WebSockets.Client (>= 4.3.2)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- System.Threading.Channels (>= 6.0.0)
-
net8.0
- Fody (>= 6.8.1)
- Microsoft.CSharp (>= 4.5.0)
- MongoDB.Bson (>= 2.21.0)
- Realm.PlatformHelpers (>= 12.3.0)
- Remotion.Linq (>= 2.2.0)
- System.Buffers (>= 4.5.1)
- System.Dynamic.Runtime (>= 4.3.0)
- System.Memory (>= 4.5.5)
- System.Net.Security (>= 4.3.2)
- System.Net.WebSockets.Client (>= 4.3.2)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- System.Threading.Channels (>= 6.0.0)
NuGet packages (39)
Showing the top 5 NuGet packages that depend on Realm:
Package | Downloads |
---|---|
ppy.osu.Game
Package Description |
|
Iridium360.Connect.Framework
This framework allows you to bind your Android or iOS device with i360RockSTAR tracker |
|
ItEnterprise.Common.CoreStandard
ItEnterprise Common.CoreStandard for Xamarin Forms |
|
Arc4u.Standard.Diagnostics.Serilog.Sinks.RealmDb
Package Description |
|
ItEnterprise.WmsStandard
ItEnterprise WmsStandard for Xamarin Forms |
GitHub repositories (7)
Showing the top 5 popular GitHub repositories that depend on Realm:
Repository | Stars |
---|---|
ppy/osu
rhythm is just a *click* away!
|
|
realm/realm-dotnet
Realm is a mobile database: a replacement for SQLite & ORMs
|
|
sgermosen/xReader
XML, NEWS, RSS & Scrapping Reader maked in Xamarin, for educational purpose.
|
|
Piotrekol/CollectionManager
An extensive tool for creating, editing, and exporting of osu! collections.
|
|
realm/realm-draw
The official Realm Draw app used in promotional videos
|
Version | Downloads | Last updated | |
---|---|---|---|
20.0.0 | 10,240 | 9/9/2024 | |
12.4.1 | 6,139 | 9/16/2024 | |
12.4.0 | 13,948 | 8/25/2024 | |
12.3.0 | 30,654 | 7/20/2024 | |
12.2.0 | 46,807 | 5/22/2024 | |
12.1.0 | 12,230 | 5/1/2024 | |
12.0.0 | 12,147 | 4/17/2024 | |
11.7.0 | 89,322 | 2/5/2024 | |
11.6.1 | 87,668 | 11/17/2023 | |
11.6.0 | 21,882 | 11/4/2023 | |
11.5.0 | 264,530 | 9/16/2023 | |
11.4.0 | 31,086 | 8/16/2023 | |
11.3.0 | 45,331 | 7/26/2023 | |
11.2.0 | 16,798 | 7/8/2023 | |
11.1.2 | 108,902 | 6/20/2023 | |
11.1.1 | 7,245 | 6/19/2023 | |
11.1.0 | 2,734 | 6/17/2023 | |
11.0.0 | 46,164 | 5/8/2023 | |
10.21.1 | 43,245 | 4/21/2023 | |
10.21.0 | 24,457 | 3/24/2023 | |
10.20.0 | 90,647 | 2/10/2023 | |
10.19.0 | 35,591 | 1/6/2023 | |
10.18.0 | 137,309 | 11/2/2022 | |
10.17.0 | 93,314 | 10/6/2022 | |
10.16.0 | 12,861 | 10/3/2022 | |
10.15.1 | 110,374 | 8/8/2022 | |
10.15.0 | 5,702 | 8/5/2022 | |
10.14.0 | 186,196 | 6/2/2022 | |
10.13.0 | 28,297 | 5/18/2022 | |
10.12.0 | 18,387 | 5/5/2022 | |
10.11.2 | 35,118 | 4/21/2022 | |
10.11.1 | 21,774 | 3/31/2022 | |
10.11.0 | 5,568 | 3/28/2022 | |
10.10.0 | 96,216 | 2/28/2022 | |
10.9.0 | 81,083 | 1/21/2022 | |
10.8.0 | 38,401 | 1/17/2022 | |
10.7.1 | 106,263 | 11/20/2021 | |
10.7.0 | 7,232 | 11/10/2021 | |
10.6.0 | 168,156 | 9/30/2021 | |
10.5.1 | 18,324 | 9/22/2021 | |
10.5.0 | 31,052 | 9/9/2021 | |
10.4.1 | 3,810 | 9/3/2021 | |
10.4.0 | 11,381 | 8/31/2021 | |
10.3.0 | 140,155 | 7/7/2021 | |
10.2.1 | 27,135 | 7/1/2021 | |
10.2.0 | 28,408 | 6/15/2021 | |
10.2.0-beta.2 | 777 | 5/5/2021 | |
10.2.0-beta.1 | 360 | 4/12/2021 | |
10.1.4 | 19,966 | 5/12/2021 | |
10.1.3 | 23,122 | 4/29/2021 | |
10.1.2 | 29,683 | 3/19/2021 | |
10.1.1 | 22,678 | 2/25/2021 | |
10.1.0 | 15,508 | 2/9/2021 | |
10.0.1 | 7,646 | 2/2/2021 | |
10.0.0-beta.6 | 442 | 1/26/2021 | |
10.0.0-beta.5 | 650 | 1/19/2021 | |
10.0.0-beta.3 | 1,164 | 12/10/2020 | |
10.0.0-beta.2 | 1,485 | 11/4/2020 | |
10.0.0-beta.1 | 744 | 10/16/2020 | |
10.0.0-alpha.43 | 371 | 10/9/2020 | |
10.0.0-alpha.34 | 481 | 10/4/2020 | |
5.1.3 | 26,476 | 2/10/2021 | |
5.1.2 | 84,480 | 10/20/2020 | |
5.1.1 | 28,005 | 10/2/2020 | |
5.1.0 | 7,523 | 9/30/2020 | |
5.0.1 | 10,856 | 9/9/2020 | |
4.3.0 | 277,965 | 2/5/2020 | |
4.2.0 | 70,312 | 10/8/2019 | |
4.1.0 | 87,676 | 8/6/2019 | |
4.0.1 | 20,394 | 6/27/2019 | |
4.0.0 | 6,329 | 6/14/2019 | |
3.4.0 | 103,817 | 1/9/2019 | |
3.3.0 | 26,464 | 11/8/2018 | |
3.2.1 | 48,774 | 9/27/2018 | |
3.2.0 | 16,952 | 9/4/2018 | |
3.1.0 | 33,106 | 7/4/2018 | |
3.0.0 | 110,089 | 4/16/2018 | |
2.2.0 | 14,626 | 3/22/2018 | |
2.1.0 | 55,244 | 11/13/2017 | |
2.0.0 | 18,423 | 10/17/2017 | |
2.0.0-rc1 | 2,631 | 10/3/2017 | |
1.6.0 | 35,591 | 8/15/2017 | |
1.5.0 | 18,033 | 6/20/2017 | |
1.4.0 | 14,952 | 5/19/2017 | |
1.3.0 | 3,765 | 5/16/2017 | |
1.2.1 | 8,006 | 5/1/2017 | |
1.2.0 | 6,006 | 4/4/2017 | |
1.1.1 | 7,551 | 3/15/2017 | |
1.1.0 | 3,726 | 3/3/2017 | |
1.0.4 | 4,954 | 2/21/2017 | |
1.0.3 | 17,111 | 2/14/2017 | |
0.82.1 | 18,524 | 1/27/2017 | |
0.82.0 | 3,439 | 1/23/2017 | |
0.81.0 | 5,538 | 12/15/2016 | |
0.80.0 | 11,657 | 10/27/2016 | |
0.78.1 | 20,642 | 9/15/2016 | |
0.78.0 | 2,784 | 9/11/2016 | |
0.77.2 | 5,657 | 8/11/2016 | |
0.77.1 | 3,217 | 7/28/2016 | |
0.76.1 | 6,109 | 6/15/2016 | |
0.76.0 | 3,463 | 6/9/2016 | |
0.75.0 | 3,285 | 6/3/2016 | |
0.74.1 | 5,934 | 5/10/2016 |
## 12.3.0 (2024-07-17)
### Deprecations
* The `Logger` has been deprecated in favor of `RealmLogger`, which `Logger` currently derives from. (PR [#3634](https://github.com/realm/realm-dotnet/pull/3634))
* The `Logger.LogLevel` `set` and `get` accessors have been deprecated. Please use `RealmLogger.SetLogLevel()` and `RealmLogger.GetLogLevel()` (see **Enhancements** below).
* The `Logger.Function(Action<LogLevel, string> logFunction)` have been deprecated. Please use `RealmLogger.Function(Action<LogLevel, LogCategory, string> logFunction)` (see **Enhancements** below).
### Enhancements
* Allow `ShouldCompactOnLaunch` to be set on `SyncConfiguration`, not only `RealmConfiguration`. (Issue [#3617](https://github.com/realm/realm-dotnet/issues/3617))
* Reduce the size of the local transaction log produced by creating objects, improving the performance of insertion-heavy transactions (Core 14.10.0).
* Performance has been improved for range queries on integers and timestamps. Requires that you use the "BETWEEN" operation in `Realm.All<T>().Filter(...)`. (Core 14.10.1)
* Allowed `ShouldCompactOnLaunch` to be set on `SyncConfiguration`, not only `RealmConfiguration`. (Issue [#3617](https://github.com/realm/realm-dotnet/issues/3617))
* Introduced a `LogCategory` and allowed for more control over which category of messages should be logged and at which criticality level. (PR [#3634](https://github.com/realm/realm-dotnet/pull/3634))
* Allowed setting and getting a `LogLevel` for a given `LogCategory`. The hierarchy of categories starts at `LogCategory.Realm`.
```csharp
RealmLogger.SetLogLevel(LogLevel.Warn, LogCategory.Realm.Sync);
RealmLogger.GetLogLevel(LogCategory.Realm.Sync.Client.Session); // LogLevel.Warn
```
* Added a function logger that accepts a callback that will receive the `LogLevel`, `LogCategory`, and the message when invoked.
```csharp
RealmLogger.Default = RealmLogger.Function((level, category, message) => /* custom implementation */);
```
* Added a `RealmLogger.Log()` overload taking a category. The pre-existing `Log()` API will implicitly log at `LogCategory.Realm.SDK`.
```csharp
RealmLogger.Default.Log(LogLevel.Warn, LogCategory.Realm, "A warning message");
```
* On Windows devices Device Sync will additionally look up SSL certificates in the Windows Trusted Root Certification Authorities certificate store when establishing a connection. (Core 14.11.0)
* Role and permissions changes no longer require a client reset to update the local realm. (Core 14.11.0)
### Fixed
* A `ForCurrentlyOutstandingWork` progress notifier would not immediately call its callback after registration. Instead you would have to wait for some data to be received to get your first update - if you were already caught up when you registered the notifier you could end up waiting a long time for the server to deliver a download that would call/expire your notifier. (Core 14.8.0)
* After compacting, a file upgrade would be triggered. This could cause loss of data if `ShouldDeleteIfMigrationNeeded` is set to `true`. (Issue [#3583](https://github.com/realm/realm-dotnet/issues/3583), Core 14.9.0)
* Passing in a deleted object as a substitution argument to `.Filter()` would throw a confusing error with a message starting with `invalid RQL for table`. It now throws a more descriptive error instead. (Issue [#3619](https://github.com/realm/realm-dotnet/issues/3619))
* Fix some client resets (such as migrating to flexible sync) potentially failing with AutoClientResetFailed if a new client reset condition (such as rolling back a flexible sync migration) occurred before the first one completed. (Core 14.10.0)
* Encrypted files on Windows had a maximum size of 2GB even on x64 due to internal usage of `off_t`, which is a 32-bit type on 64-bit Windows. (Core 14.10.0)
* The encryption code no longer behaves differently depending on the system page size, which should entirely eliminate a recurring source of bugs related to copying encrypted Realm files between platforms with different page sizes. One known outstanding bug was ([RNET-1141](https://github.com/realm/realm-dotnet/issues/3592)), where opening files on a system with a larger page size than the writing system would attempt to read sections of the file which had never been written to. (Core 14.10.0)
* There were several complicated scenarios which could result in stale reads from encrypted files in multiprocess scenarios. These were very difficult to hit and would typically lead to a crash, either due to an assertion failure or DecryptionFailure being thrown. (Core 14.10.0)
* Encrypted files have some benign data races where we can memcpy a block of memory while another thread is writing to a limited range of it. It is logically impossible to ever read from that range when this happens, but Thread Sanitizer quite reasonably complains about this. We now perform a slower operations when running with TSan which avoids this benign race. (Core 14.10.0)
* Tokenizing strings for full-text search could pass values outside the range [-1, 255] to `isspace()`, which is undefined behavior. (Core 14.10.0)
* Opening an Flexible Sync Realm asynchronously may not wait to download all data. (Core 14.10.1)
* Clearing a List of `RealmValue` in an upgraded file would lead to an assertion failing. (Core 14.10.1)
* You could get unexpected merge results when assigning to a nested collection. (Core 14.10.2)
* Fixed removing backlinks from the wrong objects if the link came from a nested list, nested dictionary, top-level dictionary, or list of `RealmValue`, and the source table had more than 256 objects. This could manifest as `array_backlink.cpp:112: Assertion failed: int64_t(value >> 1) == key.value` when removing an object. (Core 14.10.3)
* Fixed the collapse/rejoin of clusters which contained nested collections with links. This could manifest as `array.cpp:319: Array::move() Assertion failed: begin <= end [2, 1]` when removing an object. (Core 14.10.3)
* `Session.WaitForUpload()` was inconsistent in how it handled commits which did not produce any changesets to upload. Previously it would sometimes complete immediately if all commits waiting to be uploaded were empty, and at other times it would wait for a server roundtrip. It will now always complete immediately. (Core 14.10.3)
* When a property is remapped, calling `.Filter("... SORT/DISTINCT(mapped-to-name)")` with the internal name could throw an error like `Cannot sort on key path 'NAME': property 'PersonObject.NAME' does not exist`. (Core 14.10.4)
* Sync client can crash if a session is resumed while the session is being suspended. (Core 14.11.0)
* If a sync session is interrupted by a disconnect or restart while downloading a bootstrap, stale data from the previous bootstrap may be included when the session reconnects and downloads the bootstrap. This can lead to objects stored in the database that do not match the actual state of the server and potentially leading to compensating writes. (Core 14.11.0)
* Fixed unnecessary server roundtrips when there is no download to acknowledge. (Core 14.11.0)
### Compatibility
* Realm Studio: 15.0.0 or later.
### Internal
* Using Core v14.10.3.