Interface IDataFactory
A data builder which will generate items for a specific type. In many cases it will also take care of auto increasing the id and more.
[PublicApi]
public interface IDataFactory
Remarks
- Added in v15 to replace the previous IDataBuilder
Properties
ContentType
The generated ContentType. This will only be generated once, for better performance.
IContentType? ContentType { get; }
Property Value
IdCounter
A counter for the ID in case the data provided doesn't have an ID to use.
Default is 1
int IdCounter { get; }
Property Value
Relationships
TODO:
ILookup<object, IEntity> Relationships { get; }
Property Value
Methods
Create(IDictionary<string, object?>, int, Guid, DateTime, DateTime, EntityPartsLazy?)
Create a single entity based on values passed in.
IEntity Create(IDictionary<string, object?> values, int id = 0, Guid guid = default, DateTime created = default, DateTime modified = default, EntityPartsLazy? partsLazy = null)
Parameters
values
IDictionary<string, object>id
intguid
Guidcreated
DateTimemodified
DateTimepartsLazy
EntityPartsLazy
Returns
Create(IRawEntity)
Create an entity from a single ToSic.Eav.Data.Raw.Sys.IRawEntity
IEntity Create(IRawEntity rawEntity)
Parameters
rawEntity
IRawEntity
Returns
Create<T>(IEnumerable<T>)
Create a complete list of ToSic.Eav.Data.Raw.Sys.IRawEntitys. This is the method to use when you don't plan on doing any post-processing.
If you need post-processing, call Prepare
instead and finish using WrapUp
.
IImmutableList<IEntity> Create<T>(IEnumerable<T> list) where T : IRawEntity
Parameters
list
IEnumerable<T>
Returns
Type Parameters
T
Prepare<T>(IEnumerable<T>)
This will create IEntity but return it in a dictionary mapped to the original. This is useful when you intend to do further processing and need to know which original matches the generated entity.
IMPORTANT: WIP THIS ALREADY RUNS FullClone, so the resulting IEntities are properly modifiable and shouldn't be cloned again
IList<EntityPair<T>> Prepare<T>(IEnumerable<T> list) where T : IRawEntity
Parameters
list
IEnumerable<T>
Returns
- IList<EntityPair<T>>
Type Parameters
T
Prepare<T>(T)
For objects which themselves are ToSic.Eav.Data.Raw.Sys.IRawEntity
EntityPair<T> Prepare<T>(T rawEntity) where T : IRawEntity
Parameters
rawEntity
T
Returns
- EntityPair<T>
Type Parameters
T
WrapUp(IEnumerable<ICanBeEntity>)
Finalize the work of building something, using prepared materials.
IImmutableList<IEntity> WrapUp(IEnumerable<ICanBeEntity> rawList)
Parameters
rawList
IEnumerable<ICanBeEntity>