Table of Contents

Interface ICollectionMigration<TEntity>

Namespace
eQuantic.Core.Data.Migration
Assembly
eQuantic.Core.Data.dll

Fluent, typed operations against a single entity's collection/container.

public interface ICollectionMigration<TEntity> where TEntity : class

Type Parameters

TEntity

The entity type.

Methods

AddField<TField>(Expression<Func<TEntity, TField>>)

Adds the stored column for an entity member to an existing table. The member already exists on the entity (and therefore in the model); this evolves the live schema to match. Document stores gain fields on write, so the operation is a no-op there.

ICollectionMigration<TEntity> AddField<TField>(Expression<Func<TEntity, TField>> field)

Parameters

field Expression<Func<TEntity, TField>>

The member selector.

Returns

ICollectionMigration<TEntity>

Type Parameters

TField

The field type.

CompositeIndex(Action<IIndexKeyBuilder<TEntity>>, bool)

Ensures a composite (multi-key) index exists.

ICollectionMigration<TEntity> CompositeIndex(Action<IIndexKeyBuilder<TEntity>> keys, bool unique = false)

Parameters

keys Action<IIndexKeyBuilder<TEntity>>

The fluent key builder (e.g. k => k.Descending(x => x.A).Ascending(x => x.B)).

unique bool

Whether the index enforces uniqueness.

Returns

ICollectionMigration<TEntity>

ConvertField<TField>(Expression<Func<TEntity, TField>>, MigrationFieldType, MigrationFieldType)

Converts a field's stored type across existing documents (type/schema evolution).

ICollectionMigration<TEntity> ConvertField<TField>(Expression<Func<TEntity, TField>> field, MigrationFieldType from, MigrationFieldType to)

Parameters

field Expression<Func<TEntity, TField>>

The field selector.

from MigrationFieldType

The current stored type.

to MigrationFieldType

The target stored type.

Returns

ICollectionMigration<TEntity>

Type Parameters

TField

The field type.

DropField(string)

Drops a stored column/field by its stored name — the CLR member is usually already gone, so the name is a string here by design. On document stores this unsets the field across documents.

ICollectionMigration<TEntity> DropField(string field)

Parameters

field string

The stored column/field name.

Returns

ICollectionMigration<TEntity>

EnsureCollection()

Ensures the collection/container exists.

ICollectionMigration<TEntity> EnsureCollection()

Returns

ICollectionMigration<TEntity>

Index<TField>(Expression<Func<TEntity, TField>>, Action<IIndexOptions<TEntity>>)

Ensures a single-key index exists with rich, provider-interpreted options — a typed partial filter (o.Filtered(x => x.DeletedAt == null)), a structure (o.Gin(), o.Text()), a TTL (o.Ttl(...)) — each rejected with guidance by providers that cannot build it.

ICollectionMigration<TEntity> Index<TField>(Expression<Func<TEntity, TField>> field, Action<IIndexOptions<TEntity>> options)

Parameters

field Expression<Func<TEntity, TField>>

The field selector.

options Action<IIndexOptions<TEntity>>

The fluent index options.

Returns

ICollectionMigration<TEntity>

Type Parameters

TField

The field type.

Index<TField>(Expression<Func<TEntity, TField>>, bool, bool)

Ensures a single-key index exists.

ICollectionMigration<TEntity> Index<TField>(Expression<Func<TEntity, TField>> field, bool descending = false, bool unique = false)

Parameters

field Expression<Func<TEntity, TField>>

The field selector (e.g. x => x.CreatedAt).

descending bool

Whether the key is descending.

unique bool

Whether the index enforces uniqueness.

Returns

ICollectionMigration<TEntity>

Type Parameters

TField

The field type.

RenameField<TField>(Expression<Func<TEntity, TField>>, string)

Renames a field across existing documents.

ICollectionMigration<TEntity> RenameField<TField>(Expression<Func<TEntity, TField>> field, string newName)

Parameters

field Expression<Func<TEntity, TField>>

The field selector.

newName string

The new field name.

Returns

ICollectionMigration<TEntity>

Type Parameters

TField

The field type.

Update(Expression<Func<TEntity, bool>>, Action<IUpdateBuilder<TEntity>>)

Applies assignments to the documents matching a predicate (a data migration).

ICollectionMigration<TEntity> Update(Expression<Func<TEntity, bool>> predicate, Action<IUpdateBuilder<TEntity>> update)

Parameters

predicate Expression<Func<TEntity, bool>>

The predicate selecting the documents.

update Action<IUpdateBuilder<TEntity>>

The fluent assignment builder.

Returns

ICollectionMigration<TEntity>