Extending Entity with associated entity values (Show Lookup Description along with ID)

Posts   
 
    
miansi
User
Posts: 2
Joined: 16-Sep-2008
# Posted on: 03-Oct-2008 19:37:29   

Hello,

I am new to LLBLGen. I am using Adapter pattern in enterprise application:

Client Layer (Web Browser) ->(DTO)-> Presentation Layer (WCF) -> Business Layer (Facade + Business Objects (LLBLGen)) -> Data Layer (Database Specific (LLBLGen))

I have a case when I need to show let's say list of products in the grid view.

Every Product table have ProductTypeId attribute (ProductId, ProductTypeId, Name, Price), which is FK to the ProductType table (ProductTypeId , Value, Description)

Instead of converting ProductTypeId to the corresponding Description value somewhere at the page I would like to extend my Product Entity with additional field - ProductTypeDescription. I read something about projections - is this is the way to do it? Can you show me (or point to) an example please?

I expect to be able to add such an extension through the LLBLGen GUI and I was able to add some fields in "Fields mapped on related fields", but after code regeneration I wasn't able to see those fields neither in the ProductFields... Am I doing things right way?

Thank you,

Andrei

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Oct-2008 22:02:45   

Hi Andrei,

I expect to be able to add such an extension through the LLBLGen GUI and I was able to add some fields in "Fields mapped on related fields", but after code regeneration I wasn't able to see those fields neither in the ProductFields... Am I doing things right way?

If you add _ProductTypeDescription _as a field mapped on related field (from _ProductType _entity), that property will be added to Product. However the field wont be added to _ProductFields _as _ProductTypeDescription _isn't a field of _Product _entity.

See this: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=12021&StartAtMessage=0&#66749

David Elizondo | LLBLGen Support Team
miansi
User
Posts: 2
Joined: 16-Sep-2008
# Posted on: 04-Oct-2008 00:44:30   

Thank you David,

That solved my problem. Another thing to mention that you have to add ProductType to the IPrefetchPath2 and use it in adapter.FetchEntityCollection so ProductTypeDescription will be populated.

I have another question - I am using DTO templates posted in Architecture thread http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=13256 but DTO classes produced by those templates did not include my new ProductTypeDescription property. What code generation variable should I use to get the reference to the Fields on Related Fields fields?

Thank you,

Andrei

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Oct-2008 19:14:35   

<[Foreach RelatedEntityField_ CurrentRelatedEntity _Separator]> text <[NextForeach]>

You can read more on the LLBLGenPro SDK Manual, but if you already have the templates it should be easy to integrate this.

David Elizondo | LLBLGen Support Team