preFetch paths on a foreign key

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 21-Aug-2007 15:27:08   

asp.net 2.0 llblgenpro 2 adapterTemplate

hiya,

I've started using preFetch paths, and I'm hoping they can help me with the following:

I have an entityCollection, "jobItems" based on the following schema:

tblJobItem jobItemId PK assignedTOUserId FK --> tblUser.userId assignebBYUserid FK --> tblUser.userId

tblUser userId PK userName

I'm binding the jobItems entityColection to a dataGrid.

I need to be able to display the "username" for the people who:

1) assigned the job (tblJobItem.assignedTOUserId) -->tblUser.Username 2) were assigned the job (tblJobItem.assignebBYUserid) -->tblUser.Username

If prefetch paths aren't the best approach, please stop me now.

If it is, then I need to somehow do the following:

<%# Eval("User.userName") %>

..but how would I differnetiate between assignedTOUserId and assignebBYUserid?

This is the code I have so far:

 EntityCollection jobItems = new EntityCollection(new JobItemEntityFactory());
        IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.JobItemEntity);
    
        prefetchPath.Add(JobItemEntity.PrefetchPathUser);
        DataAccessAdapter adapter = new DataAccessAdapter();
        adapter.FetchEntityCollection(jobItems, null, prefetchPath);

any help appreciated.

ta,

yogi

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 21-Aug-2007 18:14:05   

You could as well try using a TypedListView if you're not intending to do editing directly on the grid.

Is kinda the same thing that you were trying to do here: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=10902

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 25-Aug-2007 18:56:02   

hiya,

thanks, I ended up just using a lookup function.But I would have use a TypedListView if there had been many.

cheers,

yogi