Table of Contents

Class EntityListExtensions

Namespace
ToSic.Eav.Data
Assembly
ToSic.Eav.Data.dll

Helper extensions for lists of entities.

[PublicApi]
public static class EntityListExtensions
Inheritance
object
EntityListExtensions

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

list IEnumerable<IEntity>
id int

Returns

bool

First(IEnumerable<IEntity>, string)

Returns the first entity that matches the specified type name, or null if not found.

public static IEntity? First(this IEnumerable<IEntity> list, string typeName)

Parameters

list IEnumerable<IEntity>

The collection of entities to search.

typeName string

The name of the type to match. This comparison is case-sensitive.

Returns

IEntity

The first entity whose type matches the specified type name, or null if no matching entity is found.

GetAll(IEnumerable<IEntity>, string)

Extract all entities of a specific content type from a list.

public static IEnumerable<IEntity> GetAll(this IEnumerable<IEntity> list, string typeName)

Parameters

list IEnumerable<IEntity>
typeName string

Returns

IEnumerable<IEntity>

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

list IEnumerable<IEntity>
guid Guid

Returns

IEntity

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

list IEnumerable<IEntity>
id int

Returns

IEntity