Hi,
Using VB, Adapter, LLBLGen 2. I find that I'm duplicating the following code, modified for different entities, to check if a record exists for one entity or another. Is it possible to produce a generic version of the code to enable me to pass in an entity name and a PK field name and so avoid the duplicated behaviour? If so, could someone help out?
Function ProductExist(ByVal aRowID As Byte) As Boolean
Dim product As New EntityCollection(Of ProductEntity)(New ProductEntityFactory())
Dim filter As IRelationPredicateBucket = New RelationPredicateBucket()
filter.PredicateExpression.Add(ProductFields.ProductID = aRowID)
Dim adapter As New DataAccessAdapter()
Try
adapter.FetchEntityCollection(product, filter, 0)
If product.Count > 0 Then
Return True
Else
Return False
End If
Finally
adapter.Dispose()
End Try
End Function
Thanks