Search code examples
asp.net-mvcvb.netllblgenpro

Using Linq with LLBLgen Pro


I am trying to do the following using MVC3, LLBLGEN PRO and it's throwing me the following error:

Mapping types: LLBLGenProQuery1 -> LLBLGenProQuery1 SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery1[[Mail.DAL.EntityClasses.TblCostCentreEntity, Mail.DAL, Version=1.0.4638.16064, Culture=neutral, PublicKeyToken=null]] -> SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery1[[Mail.Model.CostCentre, Mail.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

Destination path: LLBLGenProQuery`1

Source value: SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1[Mail.DAL.EntityClasses.TblCostCentreEntity]


Public Function GetAllCostCentres() As SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery(Of Model.CostCentre) Implements ICostCentreRepository.GetAllCostCentres

    Dim metaData As New LinqMetaData
    Dim q = From p In metaData.TblCostCentre _
                Select p
    Mapper.CreateMap(Of SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery(Of CostCentre), EntityClasses.TblCostCentreEntity)()
    Mapper.Map(Of SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery(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 q
End Function

Solution

  • Queryable

    (http://llblgen.com/documentation/3.5/LLBLGen%20Pro%20RTF/hh_goto.htm#Using%20the%20generated%20code/Linq/gencode_linq_gettingstarted.htm#LinqMetaData)

    It's a query that will make the compiler produce code which creates at runtime a tree of Expression instances, representing the entire query, in short an Expression tree. An Expression tree is not executable directly, it has to be interpreted to execute what is specified inside the Expression tree. This is what a Linq provider, like Linq to LLBLGen Pro, does: it accepts an Expression tree, translates it into elements it can understand, interprets these elements and produces an executable form of this query.

    ILLBLGenProQuery (http://llblgen.com/documentation/3.5/LLBLGen%20Pro%20RTF/hh_goto.htm#Using%20the%20generated%20code/Linq/gencode_linq_gettingstarted.htm#ILLBLGenProQuery)

    An interface defined on the IQueryable elements produced by LinqMetaData. This interface allows you to execute the query by calling the Execute method. The advantage of this is that you can get the query result in its native container, e.g. an entity collection. Another advantage is that to obtain a list of the results, the provider doesn't have to traverse the results in full, and copy over the results in a List: the returned results are already in the container they're initially stored in.