Table of Contents

Class EntityExtensions

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

WIP v21

[WorkInProgressApi("WIP v21")]
public static class EntityExtensions
Inheritance
object
EntityExtensions

Methods

AsList<TModel>(IEnumerable<IEntity?>, NoParamOrder)

public static IEnumerable<TModel> AsList<TModel>(this IEnumerable<IEntity?> entities, NoParamOrder npo = default) where TModel : class, IModelSetup<IEntity>, new()

Parameters

entities IEnumerable<IEntity>
npo NoParamOrder

Returns

IEnumerable<TModel>

Type Parameters

TModel

As<TModel>(ICanBeEntity?, NoParamOrder, bool, ModelNullHandling)

WIP Convert something which can be an entity to a model of type TModel. This is only meant for simple models that do not require a factory.

public static TModel? As<TModel>(this ICanBeEntity? canBeEntity, NoParamOrder npo = default, bool skipTypeCheck = false, ModelNullHandling nullHandling = ModelNullHandling.Undefined) where TModel : class, IModelSetup<IEntity>, new()

Parameters

canBeEntity ICanBeEntity
npo NoParamOrder

see Convention: Named Parameters

skipTypeCheck bool

allow conversion even if the Content-Type of the entity doesn't match the type specified in the parameter T

nullHandling ModelNullHandling

How to handle nulls during the conversion - default is ToSic.Eav.Data.ModelNullHandling.Default

Returns

TModel

Type Parameters

TModel

TModel must implement IWrapperSetup<IEntity> and have a parameterless constructor.

Exceptions

InvalidCastException

As<TModel>(IEntity?)

WIP Convert an IEntity to a model of type TModel. This is only meant for simple models that do not require a factory.

public static TModel? As<TModel>(this IEntity? entity) where TModel : class, IModelSetup<IEntity>, new()

Parameters

entity IEntity

Returns

TModel

Type Parameters

TModel

TModel must implement IWrapperSetup<IEntity> and have a parameterless constructor.

Exceptions

InvalidCastException

As<TModel>(IEntity?, NoParamOrder, bool, ModelNullHandling)

WIP Convert an IEntity to a model of type TModel. This is only meant for simple models that do not require a factory.

public static TModel? As<TModel>(this IEntity? entity, NoParamOrder npo = default, bool skipTypeCheck = false, ModelNullHandling nullHandling = ModelNullHandling.Undefined) where TModel : class, IModelSetup<IEntity>, new()

Parameters

entity IEntity
npo NoParamOrder

see Convention: Named Parameters

skipTypeCheck bool

allow conversion even if the Content-Type of the entity doesn't match the type specified in the parameter T

nullHandling ModelNullHandling

How to handle nulls during the conversion - default is ToSic.Eav.Data.ModelNullHandling.Default

Returns

TModel

Type Parameters

TModel

TModel must implement IWrapperSetup<IEntity> and have a parameterless constructor.

Exceptions

InvalidCastException