Table of Contents

Interface ICollectionMigration<TEntity>

Namespace
eQuantic.Core.Data.Migration
Assembly
eQuantic.Core.Data.Abstractions.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.

DropCollection(string)

Drops the collection, and everything in it. Nothing checks that this is the one you meant.

ICollectionMigration<TEntity> DropCollection(string name)

Parameters

name string

The stored name of the collection.

Returns

ICollectionMigration<TEntity>

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.

RenameCollection(string, string)

Renames the collection this entity is stored in.

ICollectionMigration<TEntity> RenameCollection(string currentName, string newName)

Parameters

currentName string

The name it is stored under today.

newName string

The name it takes.

Returns

ICollectionMigration<TEntity>

RenameField(string, string)

Renames a field, naming both sides outright.

Use this when the model has already moved on — which is always the case for a generated migration. The selector overload asks the model what the field is called today, and once the mapping has changed that answer is the new name, so the rename would resolve to a no-op while the old name stays in the store. Stating both sides describes the transition instead of the destination.

ICollectionMigration<TEntity> RenameField(string currentName, string newName)

Parameters

currentName string

The name the field is stored under today.

newName string

The new field name.

Returns

ICollectionMigration<TEntity>

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, whose current name is read from the model.

newName string

The new field name.

Returns

ICollectionMigration<TEntity>

Type Parameters

TField

The field type.

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

Restates a field's stored type to the one the model declares — how a varchar(50) becomes a varchar(200). The size is read from the model, so there is nothing to pass but the field.

A document store has no declared size, so this does nothing there rather than pretending to.

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

Parameters

field Expression<Func<TEntity, TField>>

The field selector.

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>