Table of Contents

Class IEntityExtensions

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

Extensions for IEntity to provide additional functionality or utilities.

[PublicApi]
public static class IEntityExtensions
Inheritance
object
IEntityExtensions

Remarks

Introduced in v20, moving methods which were previously in IEntity to here, since they are better as extensions.

Methods

Get<TValue>(IEntity, string)

Get a value in the expected type from this entity.

public static TValue? Get<TValue>(this IEntity entity, string name)

Parameters

entity IEntity
name string

the field/attribute name

Returns

TValue

Type Parameters

TValue

The type to try-convert the result to

Remarks

If you want to supply a fallback it will automatically use the other version of this method

History

  • Introduced as beta in 15.06, published in v17
  • Moved from IEntity to here in v20, as it is more of an extension than a core method of IEntity

Get<TValue>(IEntity, string, NoParamOrder, TValue?, string?, string?[]?)

Get a value in the expected type from this entity - or a fallback value instead.

public static TValue? Get<TValue>(this IEntity entity, string name, NoParamOrder noParamOrder = default, TValue? fallback = default, string? language = null, string?[]? languages = null)

Parameters

entity IEntity
name string

the field/attribute name

noParamOrder NoParamOrder

see Convention: Named Parameters

fallback TValue

value to be returned if finding or conversion it didn't succeed

language string

optional language like en-us

languages string[]

optional list of language IDs which can be a list which is checked in the order provided

Returns

TValue

Type Parameters

TValue

The type to try-convert the result to

Remarks

History

  • Introduced as beta in 15.06, published in v17
  • Moved from IEntity to here in v20, as it is more of an extension than a core method of IEntity