Skip to main content

ModelBuilder

Struct ModelBuilder 

Source
pub struct ModelBuilder { /* private fields */ }
Expand description

Central configuration point for the EF model.

Implementations§

Source§

impl ModelBuilder

Source

pub fn new() -> Self

Source

pub fn entity<T: IEntityType>(&mut self) -> EntityTypeBuilder<'_, T>

Source

pub fn apply_configuration<C, T>(&mut self) -> &mut Self
where C: IEntityTypeConfiguration<T> + Default + Send + Sync + 'static, T: IEntityType,

Source

pub fn build(&self) -> Vec<EntityTypeMeta>

Source

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.

Source

pub fn find_entity<T: IEntityType>(&self) -> Option<&EntityTypeMeta>

Source

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.

Source

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.

Source

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| ...).

Source

pub fn get_query_filter(&self, type_id: &TypeId) -> Option<&BoolExpr>

Source

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).

Source

pub fn seed_rows_for(&self, type_id: &TypeId) -> &[HashMap<String, DbValue>]

Returns seed rows configured via EntityTypeBuilder::has_data.

Trait Implementations§

Source§

impl Default for ModelBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.