Skip to content

EntityMapper

class in JsonApiToolkit.Mapping

Maps entity models to JSON:API resource objects. Caches property information for performance.

public static class EntityMapper

Methods

GetIdProperty(type: Type)

: PropertyInfo

Gets the primary key property for an entity. Searches for: "Id", "{TypeName}Id", or any property ending with "Id".

Parameters - type

GetAttributeProperties(type: Type)

: List<PropertyInfo>

Gets properties to map as JSON:API attributes. Excludes: ID property, relationships, non-public/unreadable properties.

Parameters - type

GetRelationshipProperties(type: Type)

: List<PropertyInfo>

Gets properties to map as JSON:API relationships. Includes collections and complex objects that have ID properties. Excludes primitives, value types, strings, DateTime, Guid, and owned entities without IDs.

Parameters - type

GetResourceType(type: Type)

: string

Gets the JSON:API resource type name (entity class name in camelCase). Example: "Person" becomes "person".

Parameters - type

GetAttributeName(property: PropertyInfo)

: string

Gets the JSON:API attribute name for a property. Centralizes name resolution so that the serializer and projection field matching always use the same logic and cannot silently diverge.

Parameters - property