Class ModelFactoryExtensions
WIP v21
[WorkInProgressApi("WIP v21")]
public static class ModelFactoryExtensions
- Inheritance
-
objectModelFactoryExtensions
Methods
As<TModel>(IModelFactory, IEntity?)
WIP, v21 requiring factory...
public static TModel? As<TModel>(this IModelFactory factory, IEntity? entity) where TModel : class, IModelSetup<IEntity>
Parameters
factoryIModelFactoryentityIEntity
Returns
- TModel
Type Parameters
TModel
Exceptions
First<TModel>(IModelFactory, IEnumerable<IEntity>?, NoParamOrder, string?)
Returns the first entity that matches the specified type name, or null if not found.
public static TModel? First<TModel>(this IModelFactory factory, IEnumerable<IEntity>? list, NoParamOrder npo = default, string? typeName = null) where TModel : class, IModelSetup<IEntity>
Parameters
factoryIModelFactoryA factory to create the target model.
listIEnumerable<IEntity>The collection of entities to search.
npoNoParamOrdertypeNamestringThe name of the type to match.
Returns
- TModel
The first entity whose type matches the specified type name wrapped into the target model, or null if no matching entity is found.
Type Parameters
TModelThe target model to convert to.
GetAll<TModel>(IModelFactory, IEnumerable<IEntity>?, NoParamOrder, string?)
Returns a collection of wrapper objects of type TModel for all entities of the specified type name.
public static IEnumerable<TModel?> GetAll<TModel>(this IModelFactory factory, IEnumerable<IEntity>? list, NoParamOrder npo = default, string? typeName = null) where TModel : class, IModelSetup<IEntity>
Parameters
factoryIModelFactoryThe factory to use for creating wrapper instances.
listIEnumerable<IEntity>The source collection of entities to search. Can be null.
npoNoParamOrdertypeNamestringThe name identifier of the entity type to filter by. This value is used to select entities of a specific type.
Returns
- IEnumerable<TModel>
An enumerable collection of TModel instances wrapping the matching entities. Returns an empty collection if the source is null or no matching entities are found.
Type Parameters
TModelThe model type to wrap each entity. Must implement
IWrapperSetup{IEntity}and have a parameterless constructor.