Skip to main content

Module relations

Module relations 

Source
Expand description

Relationship types (BelongsTo<T>, HasMany<T>, HasOne<T>).

These types serve as container wrappers for navigation properties, analogous to how EFCore represents navigation properties in the model.

They are pure marker/container types and do NOT impose entity trait bounds - ?the constraint belongs at the usage site (DbContext, builders), not on the container itself.

§Lazy loading (v1.1+)

Each container holds an optional Arc<dyn LazyContext> and a loaded flag. When lazy loading is enabled on the DbContext, to_list() attaches a LazyContext to every navigation container on every materialized entity. The user can then call nav.load().await to trigger a single-entity navigation query on first access; subsequent accesses read from the in-memory cache.

Clone intentionally drops the lazy context and resets loaded to false, matching the v1.0 semantics where cloning a navigation container yields an empty (unloaded) copy.

Structs§

BelongsTo
Represents a “belongs-to” navigation - ?the dependent side of a one-to-many or one-to-one relationship where the foreign key lives on this entity.
HasMany
Represents a “has-many” navigation - ?a collection of related entities.
HasOne
Represents a “has-one” navigation - ?a single related entity where the foreign key lives on the other side.

Enums§

DeleteBehavior
Specifies the delete behavior for a relationship. Corresponds to EFCore’s DeleteBehavior.

Type Aliases§

Through
Type alias for HasMany with an explicit join entity (many-to-many).