1
我想動態地應用表達式篩選器,並且無法使其工作。你們中的任何人都知道,如何在每個循環內應用給定的表達式過濾器,然後在匹配時返回類型t的對象?IEnumerable上的表達式篩選器
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
請問您能提供一些代碼嗎? – Baahubali
謝謝你。這樣可行!!哇噢!! – Baahubali