pub struct ModelBuilder { /* private fields */ }Expand description
Central configuration point for the EF model.
Implementations§
Source§impl ModelBuilder
impl ModelBuilder
pub fn new() -> Self
pub fn entity<T: IEntityType>(&mut self) -> EntityTypeBuilder<'_, T>
pub fn apply_configuration<C, T>(&mut self) -> &mut Self
pub fn build(&self) -> Vec<EntityTypeMeta>
Sourcepub fn entity_metas_mut(&mut self) -> &mut Vec<EntityTypeMeta>
pub fn entity_metas_mut(&mut self) -> &mut Vec<EntityTypeMeta>
Escape hatch for direct mutation of entity_metas.
Cache caveat: this returns a &mut Vec, so mutations performed
through it cannot auto-invalidate build() / filters_by_table().
Callers that mutate via this handle must drop the borrow and perform
any subsequent Fluent API mutation (or never read the caches again
in this context). Prefer register_entity_meta() / entity::<T>()
for cache-safe registration.
pub fn find_entity<T: IEntityType>(&self) -> Option<&EntityTypeMeta>
Sourcepub fn has_entity(&self, type_id: TypeId) -> bool
pub fn has_entity(&self, type_id: TypeId) -> bool
Returns true if an entity with the given type_id is already
registered in STORE B.
Sourcepub fn register_entity_meta(&mut self, meta: EntityTypeMeta)
pub fn register_entity_meta(&mut self, meta: EntityTypeMeta)
Registers an entity meta directly, without going through
entity::<T>(). Used by DbContext::discover_entities() to populate
STORE B from inventory::iter::<EntityRegistration>().
Ensures a corresponding EntityConfig entry exists so that subsequent
Fluent API calls (to_table, property_named, etc.) have somewhere
to write their overrides.
Sourcepub fn has_query_filter<T: IEntityType>(
&mut self,
filter: BoolExpr,
) -> &mut Self
pub fn has_query_filter<T: IEntityType>( &mut self, filter: BoolExpr, ) -> &mut Self
Registers a global query filter for entity type T.
Accepts a BoolExpr produced by linq!(filter |b: T| ...).
pub fn get_query_filter(&self, type_id: &TypeId) -> Option<&BoolExpr>
Sourcepub fn filters_by_table(&self) -> Arc<HashMap<String, CompiledFilter>>
pub fn filters_by_table(&self) -> Arc<HashMap<String, CompiledFilter>>
Collects all registered query filters keyed by compile-time table name
(i.e. EntityTypeMeta.table_name from #[table("...")]).
This must match the related_table stored in navigation metadata, which
is also the compile-time name — NOT the Fluent API override. If a Fluent
to_table() override renames the table, the navigation SQL and the
filter lookup both use the compile-time name, staying consistent.
Each filter is wrapped in a CompiledFilter that pre-collects parameter
values at registration time, avoiding redundant collect_bool_expr_values
traversals on every query. The SQL fragment is still compiled per query
(dialect-specific placeholders depend on the provider and query context).