Ws.Maui.LocalDB.Sync
1.0.0
dotnet add package Ws.Maui.LocalDB.Sync --version 1.0.0
NuGet\Install-Package Ws.Maui.LocalDB.Sync -Version 1.0.0
<PackageReference Include="Ws.Maui.LocalDB.Sync" Version="1.0.0" />
<PackageVersion Include="Ws.Maui.LocalDB.Sync" Version="1.0.0" />
<PackageReference Include="Ws.Maui.LocalDB.Sync" />
paket add Ws.Maui.LocalDB.Sync --version 1.0.0
#r "nuget: Ws.Maui.LocalDB.Sync, 1.0.0"
#:package Ws.Maui.LocalDB.Sync@1.0.0
#addin nuget:?package=Ws.Maui.LocalDB.Sync&version=1.0.0
#tool nuget:?package=Ws.Maui.LocalDB.Sync&version=1.0.0
Ws.Maui.LocalDB.Sync
Ws.Maui.LocalDB.Sync is a lightweight, modular sync library for .NET MAUI apps that need offline-first functionality. It provides an extensible and testable mechanism to sync remote data with a local SQLite database using a clean and pluggable architecture.
๐ Features
- โ Sync remote data into a local SQLite database
- ๐ Conflict resolution strategies (Prefer Local, Prefer Remote, Custom Merge)
- ๐งน Optional TTL (time-to-live) data pruning support
- ๐ก Incremental sync support (Last-Modified or ETag ready)
- ๐ Retry logic for remote fetch/save operations
- โ๏ธ Works great with .NET MAUI and SQLite-net-pcl
๐ฆ Installation
dotnet add package Ws.Maui.LocalDB.Sync
๐งฉ Basic Usage
1. Implement Your Entity
public class Article : ISyncableEntity<Guid>
{
public Guid Id { get; set; }
public DateTime LastModified { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}
2. Initialize a SQLiteStore
var store = new SQLiteStore<Article, Guid>("path/to/your.db");
3. Create Your SyncManager
var manager = new SyncManager<Article, Guid>(
fetchRemote: async () => await remoteService.GetArticlesAsync(),
fetchLocal: store.GetAllAsync,
saveLocal: store.SaveAsync,
resolveConflict: new PreferRemoteStrategy<Article>().Resolve
);
var results = await manager.SyncAsync();
๐ Incremental Sync Support (Advanced)
Supports tracking the last sync timestamp using ISyncMetadataProvider
:
public interface ISyncMetadataProvider<TKey>
{
Task<DateTime?> GetLastSyncedUtcAsync(TKey scope);
Task SetLastSyncedUtcAsync(TKey scope, DateTime timestamp);
}
Pass it into the SyncManager
constructor to enable automatic timestamp tracking.
๐งผ TTL Policies (Optional Pruning)
Use ITtlPolicy<T>
to delete expired records automatically:
public class ArticleTtlPolicy : ITtlPolicy<Article>
{
public bool ShouldDelete(Article article) =>
article.LastModified < DateTime.UtcNow.AddDays(-30);
}
๐ Retry & Error Handling
All fetch/save operations can be wrapped with retry logic to improve resilience:
await RetryHelper.ExecuteWithRetry(() => store.SaveAsync(items));
Each SyncResult<T>
contains an Exception? Error
field to track failed operations.
โ To Do
- TTL Pruning Support
- Retry + Error Tracking
- Incremental Sync via Metadata
- NuGet Packaging & Versioning
- Platform-specific samples (Android, Windows, etc)
๐ License
This project is licensed under the MIT License. See the LICENSE
file for details.
๐ฌ Contributing
Contributions and suggestions are welcome! Please open an issue or submit a pull request.
๐ Credits
Built with โค๏ธ for developers who need reliable offline sync in cross-platform apps.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- sqlite-net-pcl (>= 1.9.172)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 154 | 6/19/2025 |