I use an extension method for entity Framwork entity:
<Extension()>
Public Function IsExcluded(ByVal item As AnomalyProduct) As Boolean
Dim result As Boolean
If (item.WholesalerProductCode IsNot Nothing) AndAlso (item.WholesalerProductCode = _excludedChar) Then
result = True
Else
result = False
End If
Return result
End Function
I want to get a list of entity depending of the Extension Method result:
Private Function HasPacksExcluded(ByVal contextId As Guid) As Boolean
Dim result As Boolean
Dim context As ContextManager.ContextData
Dim repo As ILancelotLabEntities
context = _context.GetContext(contextId)
repo = context.RepositoryContext
result = repo.AnomalyProducts.ToList.Where(Function(p) p.IsExcluded).Any
Return result
End Function
But by this way i need to load all AnomalyProducts from Database. It take a long time just to get finally a boolean.
I think Expression Tree can help me, but i am not able to do that.
some help will be appreciated.