Skip to content

Add Support for LiteDB Serialization/Deserialization #17

@koddek

Description

@koddek

Title: Add Support for LiteDB Serialization/Deserialization

Body:

Hi,

I’d like to request support for serializing and deserializing Primitively value types with LiteDB. Currently, when attempting to use Primitively types (e.g., custom int-based value types) with LiteDB, I encounter the following error intermittently:

Method may only be called on a Type for which Type.IsGenericParameter is true.

Steps to Reproduce

  1. Define a Primitively value type, e.g., public readonly partial struct CustomerId : int {}.
  2. Use it in an entity class, e.g., public class MyEntity { public CustomerId Id { get; set; } }.
  3. Attempt to insert and retrieve the entity using LiteDB (v5.x) with the default BsonMapper.

Expected Behavior

LiteDB should serialize/deserialize the Primitively value type to/from its underlying primitive value (e.g., int) seamlessly.

Actual Behavior

Serialization/deserialization fails with the above error, likely due to LiteDB’s BsonMapper not recognizing Primitively types natively. It might be serializing the whole CustomerId vs the internal Value.

It would be great if Primitively could provide built-in support or documentation for LiteDB integration to avoid manual converter registration for each type.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions