Hi,
I am using the self servicing template and would like to loop through a collection to get each "row" as well as each related value IF there is any (while using a filter).
For example I would like all fields + the value of the metadata if it has RecordID = x.
Unfortunately lazy loading gets all rows in the metadata collection without considering the filter.
Is there any way to get around this? E.g. to get a collection based on a filter and prevent lazy loading from getting rows which don't fit into this filter?
Thanks very much
Patrick
Sample
Relationship
------------
Field.FieldId - 1:m - MetaData.FieldId / MetaData.RecordId - m:1 - Record.RecordId
TABLES
--------
Field
------
FieldId PK
FieldName
etc....
MetaData
--------
FieldId FK
RecordId FK
Value
....
Record
-------
RecordId PK
RecordName
etc....
Dim filter As New PredicateExpression(MetaDataFields.RecordId = RecordId Or MetaDataFields.RecordId = DBNull.Value)
Dim prefetch As IPrefetchPath = New PrefetchPath(EntityType.FieldEntity)
prefetch.Add(FieldEntity.PrefetchPathMetaData)
Dim relation As New RelationCollection()
relation.Add(FieldEntity.Relations.MetaDataEntityUsingFieldId, JoinHint.Left).CustomFilter = filter
Dim fieldCol As New CollectionClasses.FieldCollection
fieldCol.GetMulti(filter, 0, Nothing, relation, prefetch)
For Each fieldEnt As EntityClasses.FieldEntity In fieldCol
Dim label As String = fieldEnt.ExternalFieldLabelId
Dim value As String = String.Empty
If fieldEnt.MetaData.Count > 0 Then value = fieldEnt.MetaData(0).Value
' Add values to custom collection
dic.Add(label, value)
Next