Fields mapped on related fields for (1:n) relations

Posts   
 
    
banusi
User
Posts: 43
Joined: 08-Jul-2006
# Posted on: 11-Jun-2008 14:55:02   

Hi

When you have an entity with a (m:1) relation you can make a field mapped on related fields so it will be possible for a grid to display data from the table with primarykeys. Classic example is postal codes, where you wan't to show city in the master entity.

But I have a problem with the (1:n) relation

My tables are (only relevant fields are shown)

Table packlistHist (master table) ID, name, address and a lot more

Table UserNotes ID,packlistHistID,userid,screennote

userid can be treated just like a filter

llblgen generates UserNotes entity on the packlistHist table and I can get the info with prefetchpath, filterted with the userid. Everything works fine.

But the problem is that I wan't to make a field with screennote on the entity packlistHistentity, så that the grid (Infragistics) can show it.

How do I do that?

It's like making fields mapped on related fileds for (1:n) relations and in code. I don't think the designer can do it.

I use lllbgen 2.5 newest version and it's ok to upgrade to 2.6. I can't use Linq from 2.6 version because i am forced to use .net 2.0.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-Jun-2008 15:28:56   

You may use a flat structure like a TypedList or a DynamicList.

Otherwise packlistHist would have a collection of UserNotes entities. So whether or not you are filtering the collection to only fetch one entity, still the result is returned in a collection.

So what you can do is fetch this collection using a PrefetchPath, and in code, use something like the grid's databound event to extract the value you want to display and set it to a custom column in the grid.

banusi
User
Posts: 43
Joined: 08-Jul-2006
# Posted on: 11-Jun-2008 15:46:50   

I can not use a typed list because I have calculated fields, but the solution was easy. I just made a new field with paklisthist.usernotes[0].field if there are data and string.empty otherwise. So the solution was easy.

Thanks for the help