Magic IndexDB v1.0.11 Release Notes
🚀 Performance Overhaul, Streamed Queries, and Future-Proofed Execution
📢 NuGet Release: Magic.IndexedDb v1.0.12
- Use the v1.0.12 hotfix/patch
This update removes major bottlenecks, eliminates redundant serialization, drastically improves query performance, and introduces new future-proofed execution methods.
🔥 Key Enhancements in v1.0.11
1️⃣ Eliminated Blazor Interop Overhead – No More Double Serialization
- Removed Blazor's built-in interop handling, replacing it with a custom system using
magicDbMethods.js
. - Eliminates redundant JSON serialization & deserialization, vastly improving performance.
- 🚀 Bandwidth Increase:
- 4.4x on Blazor WASM.
- 2,250x on Blazor Server (SignalR).
2️⃣ Streamed Async Communication – No More Transfer Limits
- Moved all data transfers to streamed async communication, bypassing Blazor’s built-in size restrictions:
- ✅ No more 16MB limit on Blazor WASM.
- ✅ No more 32KB SignalR limit on Blazor Server.
- ✅ Uncapped data transfer, enabling handling of larger datasets.
- 🚀 Performance gain outweighs the minor latency increase due to eliminating double serialization.
3️⃣ New [MagicName]
Attribute – Rename Columns Without Indexing
- New
[MagicName("NewPropertyName")]
attribute allows renaming columns in IndexedDB without forcing them to be an index, unique key, or primary key. - Example Usage:
public class Person { [MagicPrimaryKey("id")] public int Id { get; set; } [MagicName("FullName")] public string Name { get; set; } }
- Results: The
Name
property is stored in IndexedDB as"FullName"
but behaves normally in C#. - Benefit: Greater flexibility in defining storage structure without unnecessary indexing.
- Results: The
4️⃣ Major Boost to where
Query Performance
- Now utilizes IndexedDB cursors instead of inefficient in-memory filtering.
- 🚀 Drastic reduction in memory usage and execution time.
Feature | Old Version | New Version | Improved? |
---|---|---|---|
Dynamically handles conditions (Equal , GreaterThan , LessThan , etc.) |
✅ Yes | ✅ Yes | ❌ No |
Supports OR conditions (jsonQueries with multiple conditions) |
✅ Yes | ✅ Yes (parallel execution) | ✅ Improved |
Supports sorting (orderBy , orderByDescending ) |
✅ Yes | ✅ Yes | ❌ No |
Supports pagination (skip , take , takeLast ) |
✅ Yes | ✅ Yes | ❌ No |
Supports indexed queries when possible | ❌ No (forced in-memory filtering via .and() ) |
✅ Yes (checks for indexed properties first) | ✅ Improved |
Supports cursor-based iteration for large datasets | ❌ No (always loads everything into memory) | ✅ Yes (avoids memory bloat with .each() ) |
✅ Improved |
Executes OR queries in parallel | ❌ No (sequential execution) | ✅ Yes (Promise.all() for speed) |
✅ Improved |
This also does mean that you can now query non indexed columns with the LINQ Where clause as long as it doesn't have the "MagicNotMapped" attribute!
🔄 Future-Proofed Query Execution – Execute()
Is Now Obsolete
- Deprecated
Execute()
and introduced new optimized methods:
Method | Description |
---|---|
ToListAsync() |
Executes the MagicQuery and returns results as List<T> . |
AsAsyncEnumerable() |
Executes the MagicQuery and returns results as IAsyncEnumerable<T> . |
{NOT YET SUPPORTED} ToList() |
(FUTURE FEATURE) Executes the MagicQuery and returns results as List<T> . |
{NOT YET SUPPORTED} AsEnumerable() |
(FUTURE FEATURE) Executes the MagicQuery and returns results as IEnumerable<T> . |
ToListAsync()
andAsAsyncEnumerable()
are now the recommended execution methods for better optimization and long-term stability.- Planned Features: Synchronous
ToList()
andAsEnumerable()
methods will be introduced in a future update. - Important note about
AsAsyncEnumerable
. The currentAsAsyncEnumerable
emulates properly providing "IAsyncEnumerable" but this feature has not yet been fully implemented. But it is a future proofed version that is safe to utilize even if full functionality isn't there yet. As it's currently just returning an IEnumerable as IAsyncEnumerable.
Complex Query Support – LINQ-Style Queries for IndexedDB
IndexedDB now supports advanced LINQ-style querying with full filtering, ordering, and pagination capabilities. Nested OR conditions is what this update brings to life. You can now build complex nested where statements in full!
Example Query:
await manager.Where<Person>(
x => x.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase)
|| x.Name.StartsWith("l", StringComparison.OrdinalIgnoreCase)
|| x.Name.StartsWith("j", StringComparison.OrdinalIgnoreCase) && x._Age > 35
).OrderBy(x => x._Id).Skip(1).ToListAsync();
People In IndexedDB!
ID | Name | Age | Not Mapped | Access |
---|---|---|---|---|
17 | Zack | 45 | CanRead | |
18 | Luna | 35 | CanRead, CanWrite | |
19 | Jerry | 35 | CanRead, CanWrite, CanCreate | |
20 | Jon | 37 | CanRead | |
21 | Jack | 37 | CanRead, CanWrite | |
22 | Cathy | 22 | CanRead, CanWrite | |
23 | Bob | 69 | CanRead | |
24 | Alex | 80 | None |
Returned Results:
Name: Cathy - Age: 22
Name: Luna - Age: 35
Name: Jon - Age: 37
Name: Jack - Age: 37
🔎 Query Breakdown:
- ✅ Filters names starting with "C", "L", or "J" (if age > 35).
- ✅ Orders by
ID
in ascending order. - ✅ Skips the first result (correct pagination support).
- ✅ Uses IndexedDB cursors to optimize execution.
🔨 Other Fixes & Enhancements
✔ Implemented cursor-based querying for non-indexed fields.
✔ Fixed complex query translation issues.
✔ Corrected camel-case property handling in attributed Magic Tables.
✔ Refactored execution commands for better usability and performance.
🔧 Upcoming Refactor – Simplifying MagicDbFactory
for Seamless Database Access
A major refactor is planned for how users interact with the MagicDbFactory
manager, aiming to eliminate all manual configuration and streamline database initialization.
🚀 What’s Changing?
- No more user input required – databases will be automatically initialized and managed.
- Simplified API usage – making Magic.IndexedDb easier to work with across multiple databases.
⚠ Known Issues & Current Limitations:
- There are existing bugs and inconsistencies when accessing multiple databases under certain scenarios.
- These issues have always existed but will be fully addressed in the upcoming refactor.
🔧 Priority Fix: This refactor is a top priority and will be implemented in an upcoming update.
📝 Final Thoughts
This release drastically enhances IndexedDB performance in Blazor, eliminates wasteful serialization, and introduces optimized, future-proofed execution methods.
📢 NuGet Release: Magic.IndexedDb v1.0.12