Hello everybody,
Could you please help me with the following issue:
I have the following function where filter is an object with a few properties. If properties have some values I have to filter against them.
Can I somehow dynamically add Where clause to Linq statement?
for example: if filter.Name <> String.Empty -> Where ac.Name = filter.Name (I'm a VB person, but not C# :-) ) and if filter.ActivityIdList isnot Nothing andalso filter.ActivityIdList.Count > 0 then I have to add condition for ac.ActivityId field.
Public Shared Function GetFieldTripDisplayList(ByVal filter As SearchCriteria) As List(Of FieldtripEntity)
Using da As IDataAccessAdapter = GetAdapter()
Dim md As New LinqMetaData(da)
If filter Is Nothing Then
Dim res = From ac In md.Fieldtrip.WithPath(
New PathEdge(Of FieldtripEntity)(FieldtripEntity.PrefetchPathFieldtripactivity),
New PathEdge(Of FieldtripEntity)(FieldtripEntity.PrefetchPathFieldtripstage))
Order By ac.Name Select ac
Return res.ToList
Else
Return Nothing
End If
End Using
End Function
Thank you very much in advance,
Galina.