Path: redb/redb.Core/Models/Entities/RedbObjectRowExtensions.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.Core/Models/Entities/RedbObjectRowExtensions.cs
----
namespace redb.Core.Models.Entities
{
///
/// The one place that turns a raw _objects row into an object header. Every provider
/// used to carry its own copy of this column list, and a column added to the row
/// (value_unique) reached some copies and not others.
///
public static class RedbObjectRowExtensions
{
/// A typed object carrying the row's header; Props stay unloaded.
public static RedbObject ToRedbObject(this RedbObjectRow row) where TProps : class, new()
{
var obj = new RedbObject();
row.ApplyHeaderTo(obj);
return obj;
}
///
/// Copies the row's header columns onto an existing object of any RedbObject shape - the
/// non-generic one, a typed one, or one created by reflection for a scheme's CLR type.
/// Props are not touched.
///
public static void ApplyHeaderTo(this RedbObjectRow row, RedbObject target)
{
target.id = row.Id;
target.name = row.Name;
target.scheme_id = row.IdScheme;
target.parent_id = row.IdParent;
target.owner_id = row.IdOwner;
target.who_change_id = row.IdWhoChange;
target.date_create = row.DateCreate;
target.date_modify = row.DateModify;
target.date_begin = row.DateBegin;
target.date_complete = row.DateComplete;
target.key = row.Key;
target.value_long = row.ValueLong;
target.value_string = row.ValueString;
target.value_guid = row.ValueGuid;
target.value_bool = row.ValueBool;
target.value_double = row.ValueDouble;
target.value_numeric = row.ValueNumeric;
target.value_datetime = row.ValueDatetime;
target.value_bytes = row.ValueBytes;
target.value_unique = row.ValueUnique;
target.note = row.Note;
target.hash = row.Hash;
}
}
}