Projection in LLBLGen Pro 2.5 Self-Servicing

Posts   
 
    
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 28-May-2008 20:19:10   

Hi all,

Is it possible to project a EntityCollectionBase into a custom data list + object, i.e. a list of DTOs?

I want something similar to the example in the documentation, but I do not want to use the DAO classes, but I want to instead project the a LLBLGen collection into my own custom collection + custom collection objects.

mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 28-May-2008 21:22:31   

Hi all,

I got projection to work with the following code:


    Protected Overridable Sub Projector(Of TDTO As {BaseDTO, New}, _
                                           TEntity As {EntityBase, IEntity})(ByVal Origin As EntityCollectionBase(Of TEntity), _
                                                                             ByRef Destination As BaseDTOCollection(Of TDTO), _
                                                                             ByVal PropertyProjectors As List(Of IEntityPropertyProjector))
        Dim _EntityView As New EntityView(Of TEntity)(Origin)

        Dim _Projector As New DataProjectorToCustomClass(Of TDTO)(Destination)

        _EntityView.CreateProjection(PropertyProjectors, _Projector)
    End Sub

Now my question is - if I have an invalid property projector setup, is it possible to throw an error? It seems right now, it just swallows it? This makes testing hard since projections are untyped.

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 29-May-2008 10:31:37   

if I have an invalid property projector setup, is it possible to throw an error? It seems right now, it just swallows it? This makes testing hard since projections are untyped.

It indeed swallows it. I'm not sure if raising an exception would be a desired behaviour. But I'll raise this issue and we will get back to you.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39872
Joined: 17-Aug-2003
# Posted on: 29-May-2008 12:18:53   

Technically it doesn't swallow it (there's no try/catch clause) but there's no checking on names if you mean that by 'invalid'.

It grabs the property descriptor matching the name, then tries to set the property through the property descriptor's SetValue method. If there's an exception, it's swallowed by the descriptor's code (read: .net code).

If you want total control, override AddProjectionResultToContainer in a derived class of DataProjectorToCustomClass and copy the code of the current method into that routine and alter the routine by adding the checks you desire.

Frans Bouma | Lead developer LLBLGen Pro