pub struct BelongsTo<T> { /* private fields */ }Expand description
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.
Corresponds to EFCore’s reference navigation property.
Implementations§
Source§impl<T> BelongsTo<T>
impl<T> BelongsTo<T>
pub fn new() -> Self
pub fn with(entity: T) -> Self
pub fn get(&self) -> Option<&T>
pub fn get_mut(&mut self) -> Option<&mut T>
Sourcepub fn take(&mut self) -> Option<T>
pub fn take(&mut self) -> Option<T>
Extracts the related entity, leaving the container empty and unloaded. Used by batch nested-include loading to collect related entities across multiple parents into a single slice for batch SQL.
Sourcepub fn is_loaded(&self) -> bool
pub fn is_loaded(&self) -> bool
Returns true if the navigation has been loaded (either eagerly
via Include or lazily via [load]).
Sourcepub fn set_lazy_context(&mut self, ctx: Arc<dyn LazyContext>)
pub fn set_lazy_context(&mut self, ctx: Arc<dyn LazyContext>)
Attaches a lazy-loading context to this container.
Called by the #[derive(EntityType)] macro’s ILazyInit
implementation when lazy loading is enabled on the DbContext.
Sourcepub async fn load(&mut self) -> EFResult<()>
pub async fn load(&mut self) -> EFResult<()>
Triggers lazy loading of this reference navigation.
If the navigation is already loaded, this is a no-op. If no
LazyContext is attached (lazy loading disabled), returns
Ok(()) without loading.
After this call, [get] returns the loaded entity (or None if
no matching row was found).