Path: redb/redb.Examples/Examples/E166_GenericNullProps.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Examples/Examples/E166_GenericNullProps.cs ---- using System.Diagnostics; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Models.Contracts; using redb.Examples.Models; using redb.Examples.Output; namespace redb.Examples.Examples; /// /// Demonstrates using generic RedbObject<TProps> with Props=null. /// Useful when you need scheme association but don't need Props values. /// Only base fields are stored - Props is explicitly null. /// [ExampleMeta("E166", "Generic with Props=null", "Core", ExampleTier.Free, 166, "Generic", "NullProps", "BaseFields", RelatedApis = ["RedbObject", "IRedbService.SaveAsync"])] public class E166_GenericNullProps : ExampleBase { public override async Task RunAsync(IRedbService redb) { var sw = Stopwatch.StartNew(); // Schemes are synced at startup; read from the scheme cache var scheme = (await redb.GetSchemeByTypeAsync())!; // Create generic object but with Props=null (only base fields) var obj = new RedbObject { name = $"GenericNullProps_{DateTime.UtcNow.Ticks}", scheme_id = scheme.Id, value_string = "MetadataOnly", value_long = 999, value_bool = true }; obj.Props = null!; // Explicitly null - no Props values // Save via interface (triggers non-Props save path) var id = await redb.SaveAsync((IRedbObject)obj); // Load as base IRedbObject (not generic) var loaded = (await redb.LoadAsync(new[] { id })).FirstOrDefault(); sw.Stop(); if (loaded == null) { return Fail("E166", "Generic with Props=null", ExampleTier.Free, sw.ElapsedMilliseconds, "Failed to load saved object."); } var result = Ok("E166", "Generic with Props=null", ExampleTier.Free, sw.ElapsedMilliseconds, 1, [$"ID: {id}, SchemeId: {loaded.SchemeId}", $"value_string: {loaded.ValueString}", $"value_long: {loaded.ValueLong} (no Props values)"]); // Cleanup await redb.DeleteAsync(id); return result; } }