mafti wrote:
hi,
i want do this
Public Function CheckEntity(ByVal _entity As EntityBase, ByVal _id As Object) As Boolean
Dim col As EntityCollectionBase
col.EntityFactoryToUse = _entity.EntityFactoryToUse
Dim filter As PredicateExpression
filter.Add(PredicateFactory.CompareValue(_entity.Fields(0).FieldIndex,
ComparisonOperator.Equal, _id))
col.GetMulti(filter, 1, Nothing, Nothing, 0, 0)
dim fk as object = col(0).Fields(1).CurrentValue
End Function
but the filter doesn't work. it won't even compile.
With compile errors, it's helpful to mention the error here so I can help you better
Your code doesn't work because you try to instantiate an abstract class (EntityCollectionBase), which doesn't work of course.
basically the function gets an id and some empty entity object. and
i want the real entity
id is the primary key field value?
What you need is also the name (or index) of the field which is the ID. If that's always index 0, you can do:
_entity.Fields(0).CurrentValue = _id
_entity.Refetch()