Class EntityViewExtensions
- Namespace
- GroupeIsa.Neos.Application
- Assembly
- GroupeIsa.Neos.Application.Abstractions.dll
Represents IEntityView<TEntityView> extensions.
public static class EntityViewExtensions
- Inheritance
-
EntityViewExtensions
- Inherited Members
Methods
AcceptChanges(IUnboundEntityView)
Accepts changes.
public static void AcceptChanges(this IUnboundEntityView entityView)
Parameters
entityViewIUnboundEntityViewEntity view.
CopyFrom<TEntity>(IBoundEntityView<TEntity>, TEntity)
Copies the properties from a source entity.
public static void CopyFrom<TEntity>(this IBoundEntityView<TEntity> entityView, TEntity entity) where TEntity : BusinessEntity
Parameters
entityViewIBoundEntityView<TEntity>The entity view.
entityTEntityThe entity.
Type Parameters
TEntityThe entity type.
GetEntity<TEntity>(IBoundEntityView<TEntity>)
Gets the entity from an entity view.
public static TEntity GetEntity<TEntity>(this IBoundEntityView<TEntity> entityView) where TEntity : BusinessEntity
Parameters
entityViewIBoundEntityView<TEntity>The entity view.
Returns
- TEntity
The entity.
Type Parameters
TEntityThe entity type.
GetOriginalOrCurrentValue<T>(IEntityView, string)
Gets the original value if the property has been modified, otherwise returns the current value.
public static T GetOriginalOrCurrentValue<T>(this IEntityView entityView, string propertyName)
Parameters
entityViewIEntityViewEntity view.
propertyNamestringThe name of the property.
Returns
- T
The original value if modified, otherwise the current value.
Type Parameters
TThe type of the property value.
Examples
int quantity = entityView.GetOriginalOrCurrentValue<int>(nameof(entityView.Quantity));
GetOriginalValue<T>(IEntityView, string)
Get the original value of property name.
public static T GetOriginalValue<T>(this IEntityView entityView, string propertyName)
Parameters
entityViewIEntityViewEntity view.
propertyNamestringThe property name.
Returns
- T
The original value if the property has been changed; throws KeyNotFoundException otherwise.
Type Parameters
TValue type.
Remarks
If you need to verify beforehand whether an original value exists for the specified property, consider using the HasOriginalValue(IEntityView, string) method.
GetState(IEntityView)
Gets the entity view state.
public static EntityViewState GetState(this IEntityView entityView)
Parameters
entityViewIEntityViewEntity view.
Returns
- EntityViewState
The entity view state.
HasOriginalValue(IEntityView, string)
Gets the value indicating whether the item has an original value.
public static bool HasOriginalValue(this IEntityView entityView, string propertyName)
Parameters
entityViewIEntityViewEntity view.
propertyNamestringThe property name.
Returns
- bool
True if the original value has a value.
Remarks
To retrieve the original value of the specified property, use the GetOriginalValue<T>(IEntityView, string) method.
IsTracked(IEntityView)
Gets a value indicating whether the entity view instance is tracked.
public static bool IsTracked(this IEntityView entityView)
Parameters
entityViewIEntityViewEntity view.
Returns
- bool
True if the instance is tracked (two-way binding with a source entity), false otherwise.
TryGetEntity<TEntity>(IBoundEntityView<TEntity>?, out TEntity)
Tries to get the entity from an entity view.
public static bool TryGetEntity<TEntity>(this IBoundEntityView<TEntity>? entityView, out TEntity entity) where TEntity : BusinessEntity
Parameters
entityViewIBoundEntityView<TEntity>The entity view.
entityTEntityThe entity.
Returns
- bool
The entity or null.
Type Parameters
TEntityThe entity type.