我试图在我的一个函数中返回一个 IQueryable 对象并使用映射(Automapper)。它设法返回一个 IEnumerable 对象,但是一旦我尝试返回一个 IQueryable 对象,它就会抛出一个错误:
这是错误:
缺少类型映射配置或不支持的映射。
映射类型:LLBLGenProQuery 1 -> CostCentre
SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery
1[[Mail.DAL.EntityClasses.TblCostCentreEntity, Mail.DAL, Version=1.0.4638.16064, Culture=neutral, PublicKeyToken=null]] -> Mail.Model.CostCentre
目的地路径:CostCentre
源值:SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1[Mail.DAL.EntityClasses.TblCostCentreEntity]
这是代码:
Dim metaData As New LinqMetaData Dim q = From p In metaData.TblCostCentre _ Select p Mapper.CreateMap(Of TblCostCentreEntity, CostCentre)()
Dim t As IEnumerable(Of CostCentre) = Mapper.Map(Of CostCentre)(q)
'Select New CostCentre With {.Active = p.Active, .CostCentre = p.CostCentre, .CreatedBy = p.CreatedBy, .DateCreated = p.DateCreated, .DateLastModified = p.DateLastModified, .ModifiedBy = p.ModifiedBy, .CostCentreID = p.CostCentreId}
Return t