RepositoryExtensions.FindExistingOrAddNewEntity<TEntity, TProjection, TPrimaryKey>(IRepository<TEntity, TPrimaryKey>, TProjection, Action<TProjection, TEntity>) Method
Returns the entity that corresponds to the specified projection.
Namespace: DevExpress.Mvvm.DataModel
Assembly: DevExpress.Mvvm.v20.2.DataModel.dll
NuGet Packages: DevExpress.Scaffolding.Core, DevExpress.WindowsDesktop.Mvvm.DataModel
Declaration
public static TEntity FindExistingOrAddNewEntity<TEntity, TProjection, TPrimaryKey>(
this IRepository<TEntity, TPrimaryKey> repository,
TProjection projectionEntity,
Action<TProjection, TEntity> applyProjectionPropertiesToEntity
)
where TEntity : class
Parameters
Name | Type | Description |
---|---|---|
repository | IRepository<TEntity, TPrimaryKey> | A repository. |
projectionEntity | TProjection | A projection. |
applyProjectionPropertiesToEntity | Action<TProjection, TEntity> | An action which applies the projection properties to the newly created entity. |
Type Parameters
Name |
---|
TEntity |
TProjection |
TPrimaryKey |
Returns
Type | Description |
---|---|
TEntity | The entity that corresponds to the specified projection. |
Remarks
Given a projection, this function returns the corresponding entity.
If the projection has no corresponding entity, a new entity is created and added to the repository.
Before the new entity is returned, the applyProjectionPropertiesToEntity action is used to transfer property values from the projection to the entity.