SchemaRegistry

Ecng.Serialization

Global registry for entity Schema metadata.

Methoden

CollectIndexes
private static ValueTuple<IReadOnlyList<SchemaColumnIndex>, bool> CollectIndexes(PropertyInfo prop)
result = SchemaRegistry.CollectIndexes(prop)

Reads every [Index] attribute on (the attribute is AllowMultiple = true) and returns one SchemaColumnIndex per declaration plus a flag set when any of the attributes is a [Unique]. [Identity] drives the schema's PK and is filtered upstream, so it never reaches this helper.

Get
public static Schema Get(Type entityType)
result = SchemaRegistry.Get(entityType)

Gets the schema for the specified entity type, creating one via reflection if not registered.

GetRelationIdentityType
private static Type GetRelationIdentityType(Type referencedType)
result = SchemaRegistry.GetRelationIdentityType(referencedType)

Gets the identity CLR type of the referenced entity type. Falls back to typeof(long) if no identity property is found.

Register
public static void Register(Schema meta)
SchemaRegistry.Register(meta)

Registers a schema for the given entity type.

RegisterTypeMapping
public static void RegisterTypeMapping(Type sourceType, Type dbColumnType)
SchemaRegistry.RegisterTypeMapping(sourceType, dbColumnType)

Registers a CLR type mapping for DB column storage.

TryGet
public static bool TryGet(Type entityType, Schema meta)
result = SchemaRegistry.TryGet(entityType, meta)

Tries to get a fully-initialised schema for the specified entity type. Schemas currently mid-build (used to break FK cycles inside Type)) are not visible here.