pub struct HasMany<T, Join = ()> { /* private fields */ }Expand description
Represents a “has-many” navigation - ?a collection of related entities.
Corresponds to EFCore’s collection navigation property
(e.g., ICollection<Post>).
Implementations§
Source§impl<T, Join> HasMany<T, Join>
impl<T, Join> HasMany<T, Join>
pub fn new() -> Self
pub fn with(items: Vec<T>) -> Self
pub fn items(&self) -> &[T]
pub fn items_mut(&mut self) -> &mut Vec<T>
pub fn add(&mut self, item: T)
pub fn remove(&mut self, index: usize) -> Option<T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
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 collection 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, [items] returns the loaded collection.
Trait Implementations§
Auto Trait Implementations§
impl<T, Join = ()> !RefUnwindSafe for HasMany<T, Join>
impl<T, Join = ()> !UnwindSafe for HasMany<T, Join>
impl<T, Join> Freeze for HasMany<T, Join>
impl<T, Join> Send for HasMany<T, Join>
impl<T, Join> Sync for HasMany<T, Join>
impl<T, Join> Unpin for HasMany<T, Join>
impl<T, Join> UnsafeUnpin for HasMany<T, Join>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more