Class EntityExtensions
WIP v21
[WorkInProgressApi("WIP v21")]
public static class EntityExtensions
- Inheritance
-
objectEntityExtensions
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
entitiesIEnumerable<IEntity>npoNoParamOrder
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
canBeEntityICanBeEntitynpoNoParamOrderskipTypeCheckboolallow conversion even if the Content-Type of the entity doesn't match the type specified in the parameter T
nullHandlingModelNullHandlingHow to handle nulls during the conversion - default is ToSic.Eav.Data.ModelNullHandling.Default
Returns
- TModel
Type Parameters
TModelTModel must implement IWrapperSetup<IEntity> and have a parameterless constructor.
Exceptions
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
entityIEntity
Returns
- TModel
Type Parameters
TModelTModel must implement IWrapperSetup<IEntity> and have a parameterless constructor.
Exceptions
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
entityIEntitynpoNoParamOrderskipTypeCheckboolallow conversion even if the Content-Type of the entity doesn't match the type specified in the parameter T
nullHandlingModelNullHandlingHow to handle nulls during the conversion - default is ToSic.Eav.Data.ModelNullHandling.Default
Returns
- TModel
Type Parameters
TModelTModel must implement IWrapperSetup<IEntity> and have a parameterless constructor.