Class EntityListExtensions
Helper extensions for lists of entities.
[PublicApi]
public static class EntityListExtensions
- Inheritance
-
objectEntityListExtensions
Remarks
Has been used internally since forever, made public in v21.
Methods
Contains(IEnumerable<IEntity>, int)
Check if an entity is available. Mainly used in special cases where published/unpublished are hidden/visible
public static bool Contains(this IEnumerable<IEntity> list, int id)
Parameters
listIEnumerable<IEntity>idint
Returns
GetAll<TModel>(IEnumerable<IEntity>?)
Returns a collection of wrapper objects of type TModel for all entities of the specified type.
public static IEnumerable<TModel> GetAll<TModel>(this IEnumerable<IEntity>? list) where TModel : IWrapperSetup<IEntity>, new()
Parameters
listIEnumerable<IEntity>The collection of entities to filter and wrap.
Returns
- IEnumerable<TModel>
An enumerable collection of wrapped entities of the specified model type. Returns an empty collection if the input is null or contains no matching entities.
Type Parameters
TModelThe model type to wrap each entity. Must implement
IWrapperSetup{IEntity}and have a parameterless constructor.
GetAll<TModel>(IEnumerable<IEntity>?, string)
Returns a collection of wrapper objects of type TModel for all entities of the specified type name.
public static IEnumerable<TModel> GetAll<TModel>(this IEnumerable<IEntity>? list, string typeName) where TModel : IWrapperSetup<IEntity>, new()
Parameters
listIEnumerable<IEntity>The source collection of entities to search. Can be null.
typeNamestringThe name identifier of the entity type to filter by. This value is used to select entities of a specific type.
Returns
- IEnumerable<TModel>
An enumerable collection of TModel instances wrapping the matching entities. Returns an empty collection if the source is null or no matching entities are found.
Type Parameters
TModelThe model type to wrap each entity. Must implement
IWrapperSetup{IEntity}and have a parameterless constructor.
GetAll<TModel>(IEnumerable<IEntity>?, NoParamOrder, string?, IWrapperFactory?)
Returns a collection of wrapper objects of type TModel for all entities of the specified type name.
public static IEnumerable<TModel> GetAll<TModel>(this IEnumerable<IEntity>? list, NoParamOrder npo = default, string? typeName = null, IWrapperFactory? factory = null) where TModel : IWrapperSetup<IEntity>, new()
Parameters
listIEnumerable<IEntity>The source collection of entities to search. Can be null.
npoNoParamOrdertypeNamestringThe name identifier of the entity type to filter by. This value is used to select entities of a specific type.
factoryIWrapperFactoryThe factory to use for creating wrapper instances.
Returns
- IEnumerable<TModel>
An enumerable collection of TModel instances wrapping the matching entities. Returns an empty collection if the source is null or no matching entities are found.
Type Parameters
TModelThe model type to wrap each entity. Must implement
IWrapperSetup{IEntity}and have a parameterless constructor.
GetOne(IEnumerable<IEntity>, Guid)
get an entity based on the guid - or null if not found
public static IEntity? GetOne(this IEnumerable<IEntity> list, Guid guid)
Parameters
listIEnumerable<IEntity>guidGuid
Returns
GetOne(IEnumerable<IEntity>, int)
Get an entity with an entity-id - or null if not found
public static IEntity? GetOne(this IEnumerable<IEntity> list, int id)
Parameters
listIEnumerable<IEntity>idint
Returns
GetOne<TModel>(IEnumerable<IEntity>?)
Returns the first entity that matches the specified type name, or null if not found.
public static TModel? GetOne<TModel>(this IEnumerable<IEntity>? list) where TModel : IWrapperSetup<IEntity>, new()
Parameters
listIEnumerable<IEntity>The collection of entities to search.
Returns
- TModel
The first entity whose type matches the specified type name wrapped into the target model, or null if no matching entity is found.
Type Parameters
TModelThe target model to convert to.
GetOne<TModel>(IEnumerable<IEntity>?, string)
Returns the first entity that matches the specified type name, or null if not found.
public static TModel? GetOne<TModel>(this IEnumerable<IEntity>? list, string typeName) where TModel : IWrapperSetup<IEntity>, new()
Parameters
listIEnumerable<IEntity>The collection of entities to search.
typeNamestringThe name of the type to match.
Returns
- TModel
The first entity whose type matches the specified type name wrapped into the target model, or null if no matching entity is found.
Type Parameters
TModelThe target model to convert to.
GetOne<TModel>(IEnumerable<IEntity>?, NoParamOrder, string?, IWrapperFactory?)
Returns the first entity that matches the specified type name, or null if not found.
public static TModel? GetOne<TModel>(this IEnumerable<IEntity>? list, NoParamOrder npo = default, string? typeName = null, IWrapperFactory? factory = null) where TModel : IWrapperSetup<IEntity>, new()
Parameters
listIEnumerable<IEntity>The collection of entities to search.
npoNoParamOrdertypeNamestringThe name of the type to match.
factoryIWrapperFactoryA factory to create the target model.
Returns
- TModel
The first entity whose type matches the specified type name wrapped into the target model, or null if no matching entity is found.
Type Parameters
TModelThe target model to convert to.