我正在尝试动态应用表达式过滤器并且无法使其正常工作。你们中的任何人都知道,如何在 for each 循环中应用给定的表达式过滤器,然后在匹配时返回类型 t 的对象?
Public Function FindByCondition( _
filter As Expressions.Expression(Of Func(Of T, Boolean))) As T Implements IRepository(Of T).FindByCondition
Dim metaData As New LinqMetaData
AutoMapper.Mapper.CreateMap(GetType(EntityType), GetEntityType)
Dim dataSource = TryCast(metaData.GetQueryableForEntity(CInt([Enum].Parse(GetType(EntityType), GetEntityType.Name))), IQueryable(Of EntityBase))
Dim q = (From p In dataSource _
Select p).ToList
Dim g = AutoMapper.Mapper.Map(Of IEnumerable(Of T))(q)
For Each k As T In g
k.Equals(filter)
Next
End Function