ObjectSpace, ORM or Serializer: Which Problem Does Each Solve?

A serializer can turn an object into bytes. An ORM can map an application model onto a relational database. An ObjectSpace can retain typed objects, indexes and identity inside an embedded store. These operations are related, but they do not answer the same engineering question.

Suppose a desktop utility needs to keep a local catalogue of documents. It must reopen its records, find a document by reference and discard an unsuccessful import. Before comparing library names, identify who will own those responsibilities. That makes the choice much clearer than asking which technology is universally best.

Different storage responsibilities represented by an object store, mappings and serialized records.
Different storage responsibilities represented by an object store, mappings and serialized records.

Contents

Start With the Persistence Boundary

A serializer defines a representation. It decides how strings, numbers, members and object references become bytes, and how those bytes become values again. It does not necessarily allocate record positions, maintain a unique index, publish a transaction or decide when a stored record is deleted. A program can add those facilities around a serializer, but that is additional storage-engine work.

An ORM maps objects to relational records. The database remains responsible for tables, SQL execution, constraints and its transaction model. This is a good fit when the application benefits from relational queries, an existing database estate or shared database administration. ObjectSpace is not an SQL server hidden behind a different name.

Sphere 10 Framework's ObjectSpace combines serializers with dimensions, recyclable storage slots, member indexes and identity tracking. Each registered CLR type has a dimension. The application can choose memory-backed storage or file-backed transactions, while keeping its model and access rules explicit.

ℹ️ An embedded store does not automatically provide a multi-process database service, arbitrary SQL or automatic schema migration. Choose those properties deliberately rather than inferring them from the word database.

Read a Small ObjectSpace Definition

This reduced in-memory configuration uses the same dimension and index registration as the complete embedded-catalogue tutorial. The downloadable example for that tutorial includes the model, storage paths and reopen checks.


var builder = new ObjectSpaceBuilder().UseMemory();
builder.AddDimension<Product>(ignoreAnnotations: true)
    .WithIdentifier(product => product.Id)
    .WithUniqueIndexOn(product => product.Sku)
    .Done();
using var store = builder.Build();
store.Load();

The important change is not fewer lines of code. The definition states that Product is a stored type, Id identifies an instance, and Sku has a unique index. The storage layer has enough information to enforce those declared access paths. A serializer alone does not express that entire contract.

Choose by the Work the Application Must Do

Requirement Natural starting point
Encode a message or file format Serializer with a deliberate layout
Work with relational tables and SQL Database plus an appropriate data-access or ORM layer
Retain indexed typed objects inside the application ObjectSpace with an explicit schema and backend
Package several binary payloads in one container Clustered streams, with application-owned metadata

These choices can coexist. A service may use a relational database for shared business records and a local ObjectSpace for a specialised catalogue. Both may consume the same binary serialization abstractions. The Framework is modular, so adopting its storage components does not require replacing every existing data system.

Make the First Test Observable

Create one record, save it, close the store and retrieve it after reopening. Then try a duplicate unique key. Those two tests establish more than a screenshot showing an object in memory because they demonstrate persistence and a declared storage rule. For file transactions, also test the difference between saving a pending record and committing it.

Start with the embedded object database tutorial , then continue to commit and rollback . The Framework ObjectSpace guide explains the underlying contracts. The practical attraction is being able to assemble the storage behaviour the application needs from one consistent toolkit.

Continue the Series

How to Build an Embedded Object Database in C#

How to Give Your C# Objects Commit and Rollback

sample.zip
Download the complete worked example and build instructions (ZIP).

For the broader Sphere 10 development toolkit, see the Sphere10 Framework overview .